My XamDataGrid has a child table that is automatially given a header identifying the entire table. The data source is a DataSet and I use the following XAML to change the title of the header:
<
igDP:Field Name="FK_Templates_BetConfiguration" Label="Bet Configuration:"/>
That works just fine. I have been unable to find a way to style the child table's label so that it doesn't affect the child table's column headers (or doesn't require me to re-write ExpandableFieldRecordPresenter). So, the natural question is how do I do this?
Thanks!
*Bump* in the naaaame of love...
Do the *bumpty* *bump*, a-do a-do the *bumpty* *bump*...
Ouch, Ouch. Here is a sample code snippet that will do the trick:
<Style TargetType="{x:Type igDP:LabelPresenter}">
<Setter Property="Background" Value="red"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=HasChildData, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:DataRecordPresenter}}}" Value="True" >
<Setter Property="Background" Value="Blue"/>
</DataTrigger>
</Style.Triggers>
</Style>
Hope this helps.
Hi Alex,
That didn't work, but I'll assume it was a problem in the way I described what I was after. I'll paraphrase. Every expandable table in my XamDataGrid has a header (it exists right above the column listing of the table). I want to style that header. My attempts to do so have failed because whenever I style the table header I end up styling the column header as well (or the alternative is nothing gets styled at all). So my question is, how do I style the table header without affecting anything else?
Thanks.
Thanks for clearing that out. You are trying to restyle the header of the expandable field record presenter and not the label presenter. In this scenario, I would go with a converter for the ExpandableFieldRecordPresenter. Here is a very simple way to achieve this:
<local:MyConverter x:Key="conv"/>
<Style TargetType="{x:Type igDP:ExpandableFieldRecordPresenter}">
<Setter Property="Background" Value="{Binding Path=Index, Converter={StaticResource conv}}"/>
class MyConverter : IValueConverter
{
public object Convert(...)
if ((int)value == 0)
return Brushes.Red;
else
return Brushes.Blue;
}
...
Here I am using the Index of the ExpandableFieldRecord so that I can identify it. You can, of course, bind to anything you want as long as it is identical for each record.
Thank you sir!
Not much.
We are trying to keep the structure similar as much as possible, unless some big change is needed.
That worked! Now that I am modifying the actual template, what is the risk with future versions of the control?
Regarding the theme,
You should place that style inside the Resources of the XamDataGrid itself, and nowhere up the element tree, as this style will not be picked up, because of the theme.
Well, you are right, my style needed some modifications, I am sorry.
I took the full style from the DefaultStyles directory in the Infragistics folder (you should have a copy of that too) and used it, because the background property is actually bound to a Grid element, which wraps everything around. What I did is changed the template binding of the background property to go to a Border element in the PART_RecordContentSize element, which is the "Header Alpha" in your case. So, the converter stays the same, just modify the style. I am attaching it in a text file, so you can copy-paste it.
Please let me know if you have further questions on this.