Hi,
I am facing issues in applying theme as well as styles on XamDataGrid. I am setting the theme
followed by some style to the XamDataGrid as follows.
<xam:XamDataGrid Name="grd" > <xam:XamDataGrid.Resources> <Style TargetType ="{x:Type xam:XamDataGrid}"> <Setter Property ="Theme" Value ="RoyaleStrong" ></Setter> </Style> <Style TargetType="{x:Type xam:DataRecordPresenter}" > <Style.Triggers> <DataTrigger Binding="{Binding Path=Record.DataItem.Age, RelativeSource={RelativeSource Self}}" Value="22"> <Setter Property="Background" Value="Green" /> <Setter Property="Style" Value="{StaticResource XamDataGridStyle}"/> </DataTrigger> </Style.Triggers> </Style> </xam:XamDataGrid.Resources> </xam:XamDataGrid>
The issue here is, the theme is getting applied, after that, the stye trigger for DataRecordPresenter also getting applied, but
the grid header's background is changed to normal gray colour. If you remove the style trigger, the grid
header's background is fine. I want the style trigger to be applied retaining the theme.
Could you please suggest a way around how to correct this issue?
Thanks in advance.
Ganesh
Alex,
I am also using the same version but in XP. Thanks for creating support case for me, Please let me know if you get any workaround.
Ganesh,
Running your sample gives me the expected results, the same as on my screenshot in my environment -
I am testing this with the latest Service Relaese for 2009.1 (9.1.20091.2049) on Vista.
If you are not using this version (with Vista), you can try installing it.
I also tested this on XP with the latest Service Release (9.1.20091.2049) and the issue occurs.
I am going to create a support case on your behalf and continue the discussion there.
Hi Alex,
Please refer the screenshot attached
Here I am trying to set the background color to green when the age is 20. (In earlier post, my code was wrong, I was trying to change the foreground color to Red. Sorry for that). I haven't done any other settings. Have also attached the sample solution. For both XBAP app and win app the behavior is same. I am using V9.1 components. Am I missing any hotfixes?
Also if possible, please send the solution that is working in your env. I will check whether the same working with my env.
Thanks,Ganesh.
Here is what I am getting:
Is there any other specific settings that you have made. Also a screenshot would help, or a sample.
Thanks
Thanks. My scenario is something like the below.
1. My XamDataGrid should be having the RoyaleStrong theme set.
2. The records in the grid should be highlighted (record's background color should be green) when
a certain condition is met. For example, if the grid contains Name and Age and if age is 20, then that
particular record should be highlighted.
I was able to do the second item without any issues. But when we set the theme for the grid, along with
the second style, the background of the column headers are disturbed. Please try the below code to
simulate the same.
<xam:XamDataGrid Name="grd" Theme="RoyaleStrong">
<xam:XamDataGrid.Resources > <Style TargetType="{x:Type xam:DataRecordPresenter}" > <Style.Triggers> <DataTrigger Binding="{Binding Path=Record.DataItem.Age, RelativeSource={RelativeSource Self}}" Value="20"> <Setter Property="Foreground" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </xam:XamDataGrid.Resources>
</xam:XamDataGrid>
and the C# code is something like this
DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("Age"); DataRow dr = dt.NewRow(); dr["Name"] = "ABC"; dr["Age"] = 28;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Name"] = "XYZ"; dr["Age"] = 20;
grd.DataSource = dt.DefaultView; grd.FieldLayoutSettings.AutoGenerateFields = true;
Please let me know whether the same issue is coming in your side also, or I am missing something here.
Many thanks in advance.
Regads,