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!
Hi Bill,
I'm happy to hear that this worked our for you. This was a really interesting case that you had. You also did a great job investigating it, and finally we both got to the result needed. Thanks for that. Now, other users may benefit from this as well. And if you have any other questions, I'll be happy to help again.
Thanks again,
Martin Stoev
Yes, that's exactly what I did. I tried it again, and I was still getting the error. Because I appreciated your good attitude and there was an example app, I went ahead and took another go at troubleshooting the error I was getting when using the TemplateColumnLayout.
As I stated before, I was getting the following error:
Message: System.InvalidOperationException: MeasureOverride of element 'Infragistics.Controls.Grids.Primitives.ColumnLayoutTemplateRowCellsPanel' should not return PositiveInfinity or NaN as its DesiredSize. at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
I thought these had something to do with my styling, but alas it was a bug in the version of Infragistics that I'm using (and I have no power to get our team to upgrade at this time :X). The bug is that if you do not explicitly set the height and width of the grid (i.e. if you let the grid stretch to its container), then it throws that error. Maybe this has been fixed in future versions, but in my version this bug exists.
So, I'm taking the minor hit of being forced to explicitly state the height and width in exchange for the cool (and really necessary) styling.
Thanks for your perseverance Martin. Much props to you and your team.
-Bill Raiford
Hello William,
I've found the solution for your issue in Silverlight. The right way was to create the custom x:Type markup, as you found in this post. You were really close to solving it. I think the best way for you to see it, is by downloading the sample I've attached. It's just a simple SL application where such functionality is achieved (even using a converter). Please, download it, examine it, and if you need some help or if you have any questions, you know we'll be glad to help. :)
Thanks,
No, I'm afraid I can't convert it to a TemplateColumnLayout. No matter what I do, I get the following error:
Error: Unhandled Error in Silverlight Application Code: 4004
Category: ManagedRuntimeError
I've tried removing all references to styles in my xaml (which I shouldn't have to do) and I still get the error. When I do a concept application, I do not get the error.
At this point, I'm about done with investing in this issue. I am simply going to mark it down as not feasible. Thanks for your time!
Hold off on that though...I had tried going back to the ColumnLayout from the TemplateColumnLayout approach. Let me try it first with the TemplateColumnLayout and embedded XamGrid and see if that works first...Thank You!