Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
524
Is there any way to set style of all the cells of xamDataGrid without referring coulumns.
posted

Hello,

Dim gridStyle As System.Windows.Style = New System.Windows.Style(GetType(CellValuePresenter))

gridStyle.Setters.Add(New System.Windows.Setter(CellValuePresenter.BorderThicknessProperty, New Thickness(0.099, 0, 0.099, 0.099)))

gridStyle.Setters.Add(New System.Windows.Setter(CellValuePresenter.BorderBrushProperty, System.Windows.Media.Brushes.Black))

Here(above) I have prepared style for a cell. Now I want to assign this style to all cells in my xamDataGrid.
  
Below is the way, in which I have to select each individual column and assign the style for each. But for this, code size get increased if
columns are large in number. Is there any way to set style of all the cells of xamDataGrid in single line...?


xamGridBuyerAvl.FieldLayouts(0).Fields(0).Settings.CellValuePresenterStyle = gridStyle
xamGridBuyerAvl.FieldLayouts(0).Fields(1).Settings.CellValuePresenterStyle = gridStyle
xamGridBuyerAvl.FieldLayouts(0).Fields(2).Settings.CellValuePresenterStyle = gridStyle

Thanking you.

  • 69686
    Verified Answer
    posted

    Hello,

    Yes there is.

    There are two ways to do this.

    If you create the style in the xaml, you can set no x:key and the style will be applied.

    The other way is to set it to the XamDataGrid.FieldSettings.CellValuePresenterStyle property.