I have the following XML (simplified example) which should have a parent/child relationship between two ComboBox's. The parent binds correctly but the child does not bind to the parents SelectedItem.
When I set xmlns against the foobar XML and remove all namespace references it works as expected. Also if I set ItemsSource="{Binding XPath=fb:foo/fb:bars/fb:bar}" against comboBar it finds all the bar nodes as expected from both foo elements.
EXAMPLE (tested to work in XamlPad)
Code:<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Page.Resources> <XmlDataProvider x:Key="foobarSource" XPath="fb:foobar"> <XmlDataProvider.XmlNamespaceManager> <XmlNamespaceMappingCollection> <XmlNamespaceMapping Prefix="fb" Uri="http://foo.bar/1.0/foobar.xsd"/> </XmlNamespaceMappingCollection> </XmlDataProvider.XmlNamespaceManager> <x:XData> <foobar xmlns="http://foo.bar/1.0/foobar.xsd"> <foo name="Foo 1"> <bars name='bars 1'> <bar name="first"/> <bar name="second"/> </bars> </foo> <foo name="Foo 2"> <bars name='bars 2'> <bar name="third"/> <bar name="fourth"/> </bars> </foo> </foobar> </x:XData> </XmlDataProvider> <DataTemplate x:Key="comboTemplate"> <TextBlock Text="{Binding XPath=@name}" /> </DataTemplate> </Page.Resources> <StackPanel DataContext="{StaticResource foobarSource}"> <ComboBox Width="150" x:Name="comboFoo" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding XPath=fb:foo}" ItemTemplate="{StaticResource comboTemplate}"/> <ComboBox Width="150" x:Name="comboBar" IsSynchronizedWithCurrentItem="True" DataContext="{Binding SelectedItem, ElementName=comboFoo}" ItemsSource="{Binding XPath=fb:bars/fb:bar}" ItemTemplate="{StaticResource comboTemplate}"/> </StackPanel> </Page>


Reply With Quote

Bookmarks