I have the following style defined in my WPF;
My problem is that this style is only applicable to one grid on the form, consequently I am getting binding errors on each of the other grids when the form loads. How do I apply this style to the appropriate grid?
Thanks in advance.
<Style TargetType="{x:Type telerik:GridViewRow}"> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=IsActive}" Value="False" /> <Condition Binding="{Binding Path=InPlan}" Value="True" /> </MultiDataTrigger.Conditions> <Setter Property="Background" Value="AntiqueWhite" /> <Setter Property="Foreground" Value="Red" /> </MultiDataTrigger> </Style.Triggers></Style>My problem is that this style is only applicable to one grid on the form, consequently I am getting binding errors on each of the other grids when the form loads. How do I apply this style to the appropriate grid?
Thanks in advance.
5 Answers, 1 is accepted
0
Hi,
You can specify a x:Key for the Style and then set is as a RowStyle of the RadGridView it is applicable for.
Let me know how this works for you.
Regards,
Didie
Telerik
You can specify a x:Key for the Style and then set is as a RowStyle of the RadGridView it is applicable for.
Let me know how this works for you.
Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Raymond
Top achievements
Rank 1
answered on 18 Dec 2013, 08:56 PM
Thanks Didie but WPF styling is not my strong point - after adding the key to the style I couldn't find where in the Gridview to set the GridViewRow style to use it;
Could you show in the code above where to markup the style.
Thanks.
<Style x:Key="InactiveGridRecord" TargetType="{x:Type telerik:GridViewRow}"> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=IsActive}" Value="False" /> <Condition Binding="{Binding Path=InPlan}" Value="True" /> </MultiDataTrigger.Conditions> </Style.Triggers></Style><telerik:RadGridView Name="gvRigList" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" telerik:StyleManager.Theme="Office_Blue" AutoGenerateColumns="False" ShowGroupPanel="True" RowIndicatorVisibility="Collapsed" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" DataLoadMode="Synchronous" ToolTip="Select a template record to edit" UseLayoutRounding="True" ShowColumnFooters="True" ShowGroupFooters="True" CanUserDeleteRows="False" CanUserInsertRows="False"> <telerik:RadGridView.Resources> <Style TargetType="ListBox"> <Setter Property="MaxHeight" Value="400" /> </Style> </telerik:RadGridView.Resources> <telerik:RadGridView.GroupDescriptors> <telerik:GroupDescriptor Member="RigClass" SortDirection="Ascending" /> <telerik:GroupDescriptor Member="RigType" SortDirection="Ascending" /> </telerik:RadGridView.GroupDescriptors> <telerik:RadGridView.Columns> <telerik:GridViewCheckBoxColumn Header="Active" UniqueName="IsActive" IsReadOnly="True" Width="auto" TextAlignment="Center" /> <telerik:GridViewCheckBoxColumn Header="In Plan" UniqueName="InPlan" IsReadOnly="True" Width="auto" TextAlignment="Center" /> <telerik:GridViewDataColumn Header="Rig Class" UniqueName="RigClass" IsReadOnly="True" Width="auto" /> <telerik:GridViewDataColumn Header="Rig Type" UniqueName="RigType" IsReadOnly="True" Width="auto" /> <telerik:GridViewDataColumn Header="Rig Name" UniqueName="RigName" IsReadOnly="True" Width="auto" /> <telerik:GridViewDataColumn Header="Current Status" UniqueName="ContractStatus" IsReadOnly="True" Width="auto" /> <telerik:GridViewDataColumn Header="From" UniqueName="FromDate" IsReadOnly="True" Width="auto"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=FromDate, Converter={StaticResource DateToText}, ConverterParameter=MediumDate}" HorizontalAlignment="Right" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="Spud" UniqueName="SpudDate" IsReadOnly="True" Width="auto"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=SpudDate, Converter={StaticResource DateToText}, ConverterParameter=MediumDate}" HorizontalAlignment="Right" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="To" UniqueName="ToDate" IsReadOnly="True" Width="auto"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=ToDate, Converter={StaticResource DateToText}, ConverterParameter=MediumDate}" HorizontalAlignment="Right" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="Confirmed RY" UniqueName="RigYearsConfirmed" IsReadOnly="True" Width="auto"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=RigYearsConfirmed, Converter={StaticResource NumberToFixedString}, ConverterParameter=0.00}" HorizontalAlignment="Right" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> <telerik:GridViewDataColumn.AggregateFunctions> <telerik:SumFunction ResultFormatString="{} {0:0.00}" /> </telerik:GridViewDataColumn.AggregateFunctions> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="Proposed RY" UniqueName="RigYearsProposed" IsReadOnly="True" Width="auto"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=RigYearsProposed, Converter={StaticResource NumberToFixedString}, ConverterParameter=0.00}" HorizontalAlignment="Right" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> <telerik:GridViewDataColumn.AggregateFunctions> <telerik:SumFunction ResultFormatString="{} {0:0.00}" /> </telerik:GridViewDataColumn.AggregateFunctions> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="Total RY" UniqueName="RigYearsTotal" IsReadOnly="True" Width="auto"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=RigYearsTotal, Converter={StaticResource NumberToFixedString}, ConverterParameter=0.00}" HorizontalAlignment="Right" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> <telerik:GridViewDataColumn.AggregateFunctions> <telerik:SumFunction ResultFormatString="{} {0:0.00}" /> </telerik:GridViewDataColumn.AggregateFunctions> </telerik:GridViewDataColumn> <telerik:GridViewDataColumn Header="Remaining RY" UniqueName="RigYearsRemaining" IsReadOnly="True" Width="auto"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=RigYearsRemaining, Converter={StaticResource NumberToFixedString}, ConverterParameter=0.00}" HorizontalAlignment="Right" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> <telerik:GridViewDataColumn.AggregateFunctions> <telerik:SumFunction ResultFormatString="{} {0:0.00}" /> </telerik:GridViewDataColumn.AggregateFunctions> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns></telerik:RadGridView>Could you show in the code above where to markup the style.
Thanks.
0
Raymond
Top achievements
Rank 1
answered on 18 Dec 2013, 09:11 PM
I tried using;
.
.
.
But this stopped the style from being applied to any of the rows?
<telerik:RadGridView Name="gvRigList" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" telerik:StyleManager.Theme="Office_Blue" AutoGenerateColumns="False" ShowGroupPanel="True" RowIndicatorVisibility="Collapsed" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" DataLoadMode="Synchronous" ToolTip="Select a template record to edit" UseLayoutRounding="True" ShowColumnFooters="True" ShowGroupFooters="True" CanUserDeleteRows="False" CanUserInsertRows="False"> <telerik:RadGridView.RowStyle> <Style x:Name="InactiveGridRecord" /> </telerik:RadGridView.RowStyle> .
.
.
</telerik:RadGridView>But this stopped the style from being applied to any of the rows?
1
Accepted
Hello,
You can explicitly apply the Style using one of the following two approaches:
1.
2.
Regards,
Didie
Telerik
You can explicitly apply the Style using one of the following two approaches:
1.
<telerik:RadGridView ... RowStyle="{StaticResource InactiveGridRecord}"><telerik:RadGridView.RowStyle> <Style TargetType="{x:Type telerik:GridViewRow}"> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=IsActive}" Value="False" /> <Condition Binding="{Binding Path=InPlan}" Value="True" /> </MultiDataTrigger.Conditions> </MultiDataTrigger> </Style.Triggers> </Style></telerik:RadGridView.RowStyle>Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Raymond
Top achievements
Rank 1
answered on 19 Dec 2013, 08:40 PM
Thanks Didie - worked a treat...