icsharpcode / WpfDesigner

The WPF Designer from SharpDevelop
MIT License
949 stars 251 forks source link

Selection Handling on Design Surface #48

Closed khalili-mahdi closed 6 years ago

khalili-mahdi commented 6 years ago

i'm using this code to change SelectionChanged handler on DesignSurface

 designSurface.DesignContext.Services.Selection.SelectionChanged += delegate
            {
                   var selection = designSurface.DesignContext.Services.Selection.SelectedItems.First().Component ;
                   CommandManager.InvalidateRequerySuggested();
            };

i feel like its wrong what is the correct way to do this in DesignSurface ? i need to get data from Selected Item but its not DesignItem , i've Added My own Control to it

jogibear9988 commented 6 years ago

Again, I don‘t understand the question! But you could use PrimarySelection instead of SelectedItems

khalili-mahdi commented 6 years ago

i have items on design surface i could select them, so i need to add event for onSelectionChanged what is right way to do that?

jogibear9988 commented 6 years ago

whats wrong with

   designSurface.DesignContext.Services.Selection.SelectionChanged
khalili-mahdi commented 6 years ago

sorry my fault this one is totally working