Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
215
Heirarchical Binding to Parent Row (Silverlight, MVVM)
posted

Greetings!

I'm having a problem trying to bind a heirarchical column style to its parent row's DataContext in xaml.

My grid's datasource is a collection of ViewModels, each of which has a property MyProperty. I need to set a style on a border that is in a datatemplate inside of a TemplatedColumn in a ColumnLayout inside of the grid, according to that parent ViewModel.MyProperty value (with a converter of course). That's a lot of nesting!

Here is a sketch of my problem:

<ig:XamGrid ItemsSource="{Binding Path=ItemViewModels}">

...

    <ig:ColumnLayout>               <<<<<<child level in heirarchy

    ...

      <ig:TemplateColumn Key="SomeColumn">

        <ig:TemplateColumn.ItemTemplate>  

         <DataTemplate>            

            <Border BorderBrush="{Binding RowData Path=MyProperty, Converter={StaticResource MyPropertyToBrushConverter}}"> //This does not work obviously, since I'm posting!

     ... 

 

 

I'd appreciate any help you can give!

Parents
No Data
Reply
  • 775
    posted

    Hello William,

        Thank you for your post. There is a quick solution for your issue - change the <ig:ColumnLayout> to <ig:TemplateColumnLayout> (since you are using <ig:TemplateColumn> inside). Also don't forget to set the "Key" property on the ig:TemplateColumnLayout. After doing that, all of the bindings should work fine.

    You can refer to this sample for a quick demo on how to set it all up.

    If that happens not to be your case, then you could share a samples and we'll be happy to help.

    Thanks,

    Martin Stoev

Children