Static Resource Value from Binding Question


  • I have a UserControl that has a DataGrid on it.  It is bound to a Public Property in my ViewModel.

    One of the columns on the grid needs to be bound to a global boolean in the ViewModel.  That is to say, a ViewModel Property, not a property in the Object the Grid is Bound too.

    Doesn't look like you can do:

    <sys:Boolean x:Key="ManagedSignedFormsAuthorization">{Binding MyViewModelBoolean}</sys:Boolean>

    So I want to bind a column in my grid to a StaticResource and the StaticResource needs to get its value from the ViewModel.

    Friday, April 20, 2012 1:03 PM


  • Hi maikeu-sama,

    Please follow below code

    In ViewModel add a public property of bool type

    public bool  isFalse {get;set;}

    In MainPage.xaml

            <local:ViewModel x:Key="ViewModel" /> //here local namespace is refered to current project.



                    <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" >
                                <CheckBox IsChecked="{Binding isFalse, Source={StaticResource ViewModel}}" />




    Best Regards,

    Thursday, April 26, 2012 12:22 PM