Will there be RelativeSource FindAncestor, AncestorType... in Silverlight 4?
+7
A:
In Silverlight 4 the RelativeSource
property of Binding
still only supports "Self" and "TemplatedParent", there is no change from Silverlight 3 in this area.
AnthonyWJones
2010-02-18 21:24:32
Well i agree! but this should be a comment not a question?
Petoj
2010-08-05 09:41:17
A:
This may help:
http://blog.thekieners.com/2010/09/08/relativesource-binding-with-findancestor-mode-in-silverlight/
synergetic
2010-09-18 10:33:19
A:
Perhaps you could instantiate the ViewModel in the XMAL as a static resource then reference that as the source in your binding.
<UserControl.Resources>
<vm:MainPageViewModel x:Key="ViewModel"/>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource ViewModel}}">
<ListBox ItemsSource="{Binding Partitions}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel FlowDirection="LeftToRight" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Margin="10,0" Width="40" Content="{Binding}" Command="{Binding Source={StaticResource ViewModel}, Path=ButtonCommand}" CommandParameter="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
Ralph Shillington
2010-10-08 11:48:38