Home Forums WPF controls Xceed DataGrid for WPF Setting the FixedHeaders from a style

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

    Since all of the DataGridControl instances in my app have the same general View layout, I’d really like to do something like this in my application style:

    <Style TargetType=”{x:Type xcdg:TableView}”>
    <Setter Property=”ShowRowSelectorPane” Value=”False” />
    <Setter Property=”ShowFixedColumnSplitter” Value=”False” />
    <Setter Property=”FixedHeaders”>
    <Setter.Value>
    <xcdg:ClearHeadersFooters/>

    <DataTemplate>
    <xcdg:ColumnManagerRow MinWidth=”{Binding RelativeSource={RelativeSource AncestorType={x:Type ScrollContentPresenter}}, Path=ActualWidth}”/>
    </DataTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    However, since the FixedHeaders collection property only has a get accessors, I’m unable to set this property from a Style Settter.

    Does anyone have a reasonable workaround?

    Imported from legacy forums. Posted by John (had 1941 views)

    User (Old forums)
    Member
    Post count: 23064

    I found a workaround.

    I added the following to my DataGridControl’s global style:

    <EventSetter Event=”Loaded” Handler=”DataGrid_Loaded” />

    Then, in the code-behind for my style resource dictionary, i added this:

    private void DataGrid_Loaded(object sender, RoutedEventArgs e)
    {
    DataGrid dataGrid = (DataGrid)e.Source;
    if (dataGrid.View != null)
    return;

    TableView tableView = new TableView();
    tableView.FixedHeaders.Clear();

    DataTemplate dataTemplate = (DataTemplate)
    Application.Current.FindResource(“TableViewFixedHeadersColumnManagerRowDataTemplate”);
    tableView.FixedHeaders.Add(dataTemplate);

    dataGrid.View = tableView;
    }

    Imported from legacy forums. Posted by John (had 3086 views)

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