Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight - bind from DataGrid column back to root property of view model?
    primarykey
    data
    text
    <p>I have the following XAML:</p> <pre><code>&lt;UserControl.Resources&gt; &lt;local:MainPageViewModel x:Key="ViewModel" /&gt; &lt;/UserControl.Resources&gt; &lt;Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource ViewModel}}"&gt; &lt;sdk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Items}"&gt; &lt;sdk:DataGrid.Columns&gt; &lt;sdk:DataGridTextColumn Header="ID" Binding="{Binding ID}" /&gt; &lt;sdk:DataGridTextColumn Header="Name" Binding="{Binding Name}" /&gt; &lt;sdk:DataGridCheckBoxColumn Header="Checkbox Column" Binding="{Binding Source={StaticResource ViewModel}, Path=SomeBooleanProperty}"/&gt; &lt;/sdk:DataGrid.Columns&gt; &lt;/sdk:DataGrid&gt; &lt;/Grid&gt; </code></pre> <p>So, basically I want to have one of the columns (the checkbox column) bound to some property (SomeBooleanProperty) that is directly on the ViewModel, as opposed to a property on one of the items in the Items collection. (Yes this is a bit contrived, but it gets to my problem.) The problem is that based on my testing, if you bind via the StaticResource, it seems like the value isn't updated based on INotifyPropertyChanged event firing. The initial value is correct, but it never changes. I can't figure out another way to get "out" of the Items binding and back up to the ViewModel, from within a column binding.</p> <p>I think that in WPF you could do this with a RelativeBinding using FindAncestor. But that functionality doesn't exist in Silverlight. Are there other ways to accomplish this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload