Karl_Schuhmann
Karl_Schuhmann

Reputation: 1332

CanUserResize=false for DataGridRowHeader

You can disable resizing the columns of a datagrid.

Is there a way to stop resizing the rowsheader Height

At this moment the user can resize the row Headers. Like this:

Guten Tag

I want to disable this. So it should always look:

enter image description here

That's my RowHeaderTemplate

         <DataGrid.RowHeaderTemplate>
            <DataTemplate>
                <DockPanel FlowDirection="LeftToRight" DataContext="{Binding Item,RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}">
                    <TextBlock Text="{Binding ZimmerNummer}" MinWidth="48" MaxWidth="48" />
                </DockPanel>
            </DataTemplate>
        </DataGrid.RowHeaderTemplate>

That was my idea:

<DataGrid.RowHeaderStyle>
    <Style TargetType="DataGridRowHeader">
        <Setter Property="MaxHeight"
            Value="55"/>
    </Style>
</DataGrid.RowHeaderStyle>

But it was not work. That was the result:

enter image description here

Do someone know a Solution for that?

Upvotes: 10

Views: 6784

Answers (1)

dkozl
dkozl

Reputation: 33364

If you want to disable resizing on your DataGrid then you can do something like this:

<DataGrid CanUserResizeColumns="False" CanUserResizeRows="False" .../>

Upvotes: 25

Related Questions