We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Binding to SelectedItems property

Thread ID:

Created:

Updated:

Platform:

Replies:

127572 Nov 24,2016 06:18 AM Dec 7,2016 11:47 PM WPF 3
loading
Tags: SfDiagram
Artemy
Asked On November 24, 2016 06:18 AM

Hello,

Q: What is a proper way to bind SfDiagram.SelectedItems property to ViewModel's corresponding property?
Tried the following:

XAML:

<sf:SfDiagram.SelectedItems>
    <sf:Selector DataContext="{Binding SelectedItems}"/>
</sf:SfDiagram.SelectedItems>

(assuming that DataContext is a VM object)

In VM:

private SelectorViewModel selectedItems = new SelectorViewModel() {
Nodes = new ObservableCollection<NodeViewModel>(),
Connectors = new ObservableCollection<ConnectorViewModel>();
};
public SelectorViewModel SelectedItems {
get { return selectedItems; }
set {
selectedItems = value;
OnPropertyChanged(nameof(SelectedItems));
}
}

but getting an Exception after trying to select something (even the diagram itself).

Ranjitha Amirthalingam [Syncfusion]
Replied On December 1, 2016 04:33 AM

Hi Artemy, 
 
Thanks for Contacting Syncfusion Support. 
 
Requirement: To bind the custom ViewModel for Selected Items. 
 
The SelectedItems property of SfDiagram is type of SelectorViewModel which is the default DataContext of Selector. We assumed that your requirement is to bind the SelectorViewModel (from ViewModel class) to SelectedItems property of SfDiagram. We have represented this in simple sample. Please refer to that as below. 
 
 
Sample Details: 
We have created ViewModel (named as “DiagramVM”) for Diagram with Custom property for SelectedItems. 
  
Regards, 
Ranjitha A. 


Artemy
Replied On December 6, 2016 06:31 AM

Thank you 

Keerthivasan Ramamoorthy [Syncfusion]
Replied On December 7, 2016 11:47 PM

Hi Artemy,  
Thanks for the update.  
Please let us know if you need any other assistance.   
   
Regards,   
Keerthivasan R.   


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;