This is a migrated thread and some comments may be shown as answers.

RadGridView RowStyle is not working

2 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ivan Kopcanski
Top achievements
Rank 1
Ivan Kopcanski asked on 19 Apr 2010, 03:00 PM
Hi,
    I have inherited RadGridView control with applied row style:

<telerik:RadGridView  
   xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    x:Class="DCMS.FrontEnd.SL.CustomControls.RadGrid" ...>
    
    
    FontFamily="Arial Unicode MS"
    Style="{StaticResource ListScreenGridViewData}"
    RowStyle="{StaticResource ListScreenGridViewRow2}"
    HeaderRowStyle="{StaticResource GridViewHeaderRowStyle}"
    AutoGenerateColumns="False" 
    SelectionMode="Extended" 
    Sorting="gvData_Sorting" ShowGroupPanel="False" 
    SelectionChanged="gvData_SelectionChanged" 
    CellValidating="gvData_CellValidating"
    CellEditEnded="gvData_CellEditEnded"> ...</telerik:RadGridView>

------------------------------ The following style is in the merged dictionary ----------------------------------

 <Style x:Key="ListScreenGridViewRow2" TargetType="gridNamespace:GridViewRow">
        <Setter Property="Background" Value="White"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="MinHeight" Value="24"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Foreground" Value="#FF000000"/>
    </Style>



Working this way the row style is applied correctly. But when I put this control in the UserControl:



<UserControl 
    xmlns:custom="clr-namespace:DCMS.FrontEnd.SL.CustomControls"  
    x:Class=".DCMS.FrontEnd.SL.CustomControls.Grid" ...>

    <StackPanel x:Name="spData" 
                Orientation="Vertical" SizeChanged="spData_SizeChanged">
        <custom:RadGrid   
                                    Style="{StaticResource ListScreenGridViewData}"
                                    RowStyle="{StaticResource ListScreenGridViewRow2}"
                                    HeaderRowStyle="{StaticResource GridViewHeaderRowStyle}"
                                    Grid.Column="0"
                                    Grid.Row="0"
                                    x:Name="gvData"
                                    FontFamily="Arial Unicode MS"
                                    AutoGenerateColumns="False"
                                    Sorting="gvData_Sorting"
                                    ShowGroupPanel="False"
                                    SelectionChanged="gvData_SelectionChanged" />
...
</UserControl>

I can't make the inherited RadGridView in user control to use referenced RowStyle when I use it in UserControl.
Can you please point out the mistake I'm making, if you see something that I don't?

2 Answers, 1 is accepted

Sort by
0
Accepted
Jim Daly
Top achievements
Rank 1
answered on 19 Apr 2010, 07:35 PM
Your row style would have to be defined in either the Resources section of the UserControl, or in a ResourceDictionary in order for your RadGridView to be able to reference it:

Try adding this before your StackPanel:

    <UserControl.Resources>
        <Style x:Key="ListScreenGridViewRow2" TargetType="gridNamespace:GridViewRow">
            <Setter Property="Background" Value="White"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="MinHeight" Value="24"/>
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Foreground" Value="#FF000000"/>
        </Style>
    </UserControl.Resources>

You're actually better off puting it in a ResourceDictionary though, so that you can apply it to RadGridViews that are in UserControls across your app.



0
Ivan Kopcanski
Top achievements
Rank 1
answered on 21 Apr 2010, 08:53 AM
Hi,

The problem is resolved, the merged dictionary was not visible.


Tags
GridView
Asked by
Ivan Kopcanski
Top achievements
Rank 1
Answers by
Jim Daly
Top achievements
Rank 1
Ivan Kopcanski
Top achievements
Rank 1
Share this question
or