Home Dashboard Directory Help
Search

FindAncestor RelativeSource should be available in Silverlight by StefanOlson


Status: 

Active


68
0
Sign in
to vote
Type: Suggestion
ID: 480603
Opened: 8/3/2009 7:51:11 PM
Access Restriction: Public
1
Workaround(s)
view

Description

Silverlight 3 implemented partial support for relative source binding. Silverlight should support FindAncestor relative source binding. e.g:
{Binding Path=IsMouseOver,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}

This would make it possible to do in Xaml many things that are currently having to be done in thousands of extra lines of code in Silverlight. It would also improve consistency with WPF, a major problem with Silverlight.
Details
Sign in to post a comment.
Posted by TravisWhidden on 5/18/2010 at 11:27 AM
+1 -- also +1 on Aquilax
Posted by Aquilax on 12/9/2009 at 6:36 AM
This would be also useful to escape from the data template context and get the parent control context:

<DataGrid DataContext="{Binding MyViewModel}" ItemsSource="{Binding ProductSet}">
<DataGrid.Columns>
    <DataGridTemplateColumn>
     <DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
         <ComboBox DisplayMemberPath="ProductTypeName" SelectedItem="{Binding ProductType,Mode=TwoWay}" ItemsSource="{Binding ProductTypeSet,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}}" />
        </DataTemplate>
     </DataGridTemplateColumn.CellEditingTemplate>
    </DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Posted by Microsoft on 8/4/2009 at 8:33 PM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Dave A-W on 7/7/2010 at 1:01 AM
http://www.scottlogic.co.uk/blog/colin/2009/02/relativesource-binding-in-silverlight/