Home Forums WPF controls Xceed DataGrid for WPF How to apply custom style on datarow?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #22124 |

    Hi,

    I am facing a problem when i am going to apply style on datarow.
    <Style x:Key=”datarow_style” TargetType=”{x:Type xcdg:DataRow}”>

    If I don’t apply style on row then I get a default style(row in light skycolor) when
    selecting row.
    But once style is applied on datarow,i don’t get that style. so i am unable to
    identify rows which are selected.

    Can anyone help me please how can i apply custom style on selection of datarow?

    Thanks in advance
    Debkumar

    Imported from legacy forums. Posted by debkumar (had 3162 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    In order to apply a style on the DataRows, you need to either specify the style as “implicit”:

    <code>
    <Window.Resources>
    <!– An implicit style is a style that have no “key”, only a TargetType –>
    <Style TargetType=”{x:Type xcdg:DataRow}”/>
    </Window.Resources>
    </code>

    Or to assign the style explicitelly to the “ItemContainerStyle” property of the DataGridControl.

    <code>
    <Window.Resource>
    <Style x:Key=”datarow_style” TargetType=”{x:Type xcdg:DataRow}”/>
    </Window.Resource>

    <xcdg:DataGridControl ItemContainerStyle=”{StaticResource datarow_style}”/>
    </code>

    While we have no hook to affect a particular style on a DataRow when it becomes selected, it is possible to specify in your Style a trigger for the “IsSelected” property and place the setters you need.

    In the style, you can set the “SelectionBackground” property to change the brush used when the row is selected, but be warned that the Aero look does not use the “SelectionBackground” property because the required visual effect is too complex… For the Aero theme, to change this, you will need to make a copy of the ControlTemplate for the DataRow (provided with the package) and modify it to your needs.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 3960 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marc,

     Thanks for the note about Aero look…I’ve spent some days trying to change tge SelectionBackground of the selected row with Aero look….now I know the reason :O

    Could you help me to do it please? Do you have an example?

    How can I “make a copy of the ControlTemplate for the DataRow) and modify it?

    Waiting for your answer…
    Best,
    Zsombor

    Imported from legacy forums. Posted by Zsombor (had 482 views)

    Xceed Support
    Member
    Post count: 5658

    In the “themes” folder that was installed with the grid you will have the XAML files that contain the templates and styles.  You can open the ones for the Aero theme and retrieve the DataRow template there.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 224 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you for your answer! I’ll try to solve it.

    Anyway do you now why should I modify all of the namespace references in your theme files for example from

    xmlns

    :local=”clr-namespace:Xceed.Wpf.DataGrid”

    to

    xmlns

    :local=”clr-namespace:Xceed.Wpf.DataGrid;assembly=Xceed.Wpf.DataGrid”

      So without defining the assembly it doesn’t compile – I’ve the Xceed.Wpf.DataGrid / Contols in the references.

    Do you know? (I’m sure)

    Best!

     

     

     

    Imported from legacy forums. Posted by Zsombor (had 3019 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.