Reputation: 581
how can i bind the data returning from WCF in combox in grid . the combobox is not in edit mode. I am able to display the static data but not the data returning from WCF.
Upvotes: 1
Views: 1868
Reputation: 3766
I'm assuming the static data is the stuff you enter into the Items property by hand. The syntax for a combobox is a bit different, but here it is:
<ComboBox ItemsSource="{Binding Path=<your collection>,Mode=OneTime}" SelectedValuePath="<id-field>" DisplayMemberPath="<display-field>" SelectedItem="{Binding Path=<your-property>,Mode=TwoWay}" />
The parameters ending in PATH above just have the names of the properties as a string.
EDIT: If you're using a dictionary, you would use:
<ComboBox ItemsSource="{Binding Path=<your dictionsry>,Mode=OneTime}" SelectedValuePath="Key" DisplayMemberPath="Value" SelectedItem="{Binding Path=<your-int-property>,Mode=TwoWay}" />
Upvotes: 0
Reputation: 7082
u can use RelativeSource to search needed DataContext/ViewModel/Page/UserControl in the elements tree example for the ViewModel where DataGrid itemssource defined near ComBoxCollectionSource:
<ComboBox ItemsSource={Binding RelativeSource={RelativeSource AncestorType=sdk:DataGrid}, Path=DataContext.ComboBoxColloctionSource} />
Upvotes: 2