Съезжает таблица с данными DataGrid WPF

В общем, первый скрин это до того, как увеличили приложение на весь экран. Как можно заметить, таблица с данными вмещается. После увеличения приложения во весь экран и обратном уменьшении данные таблицы съезжают и правую часть не видно полностью. Даже скролл потерялся Реализация этой таблицы происходит так: Window с меню, Frame с datagrid, page, который при выборе меню передает соотвествующий page Основной код datagrid:

<Page x:Class="DesignTaburetka.Pages.Clients"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:f="http://schemas.awesome.incremented/wpf/xaml/fontawesome.sharp"
  xmlns:local="clr-namespace:DesignTaburetka.Pages"
  mc:Ignorable="d" 
  Height="Auto" Width="Auto"
  Title="Clients">

<Grid Background="Transparent" >
    <DataGrid Name="ClientsData"  
              Margin="5,5,5,50" 
              ItemsSource="{Binding }"  RowStyle="{StaticResource DataRowStyle}"
              CellStyle="{StaticResource DataCellStyle}"
              Style="{StaticResource DataStyle}"
              ColumnHeaderStyle="{StaticResource HeaderStyle}" 
             >
        <DataGrid.Columns>
            <DataGridTextColumn Header="id" Binding="{Binding Path='client_id'}" IsReadOnly="True" Width="Auto" SortDirection="Ascending" CanUserSort="True"/>
            <DataGridTextColumn Header="Имя Клиента" Binding="{Binding client_name}" Width="*" CanUserSort="True"/>
            <DataGridTextColumn Header="Телефоны" Binding="{Binding Path='client_phone'}" Width="*" CanUserSort="True"/>
            <DataGridTextColumn Header="Адрес" Binding="{Binding Path='client_address'}" Width="*" CanUserSort="True"/>
            <DataGridTextColumn Header="Тип клиента" Binding="{Binding Path='ClientType'}" Width="*" CanUserSort="True"/>
            <DataGridTextColumn Header="Комментарий" Binding="{Binding Path='Comment'}" Width="*" CanUserSort="False"/>
            <DataGridTemplateColumn Width="Auto" CanUserSort="False">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Button Name="BtnDeleteClient" Click="BtnDeleteClient_Click" Style="{StaticResource IconButtonsStyle}" 
                                Tag="IsCloseButton" Cursor="Hand" Content="{f:Icon MinusCircle}">
                            
                        </Button>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>
    <Button Name="BtnAddClient" Content="Добавить" HorizontalAlignment="Right" VerticalAlignment="Bottom" 
            Margin="10" Click="BtnAddClient_Click"  Width="100" Height="30" Style="{StaticResource btnAddClient}" >
        <Button.Template>
            <ControlTemplate>
                <Border CornerRadius="5" Background="{TemplateBinding Background}">
                    <ContentPresenter Content="Добавить" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </ControlTemplate>
        </Button.Template>

    </Button>
</Grid>

Код стилей:

    <Style x:Key="DataRowStyle" TargetType="{x:Type DataGridRow}">
        <Setter Property="Margin" Value="0 4 0 0" />
        <Setter Property="Height" Value="Auto"/>
        <Setter Property="Background" Value="WhiteSmoke"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
        <Setter Property="ValidationErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <TextBlock Foreground="#003b46" Margin="2,0,0,0" Text="!" VerticalAlignment="Center" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRow}">
                    <Border CornerRadius="5" Background="{TemplateBinding Background}" BorderThickness="0" SnapsToDevicePixels="True" >
                        <SelectiveScrollingGrid>
                            <DataGridCellsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </SelectiveScrollingGrid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="#D9DAFF"/>
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="#003b46"/>
                <Setter Property="Foreground" Value="#ffffff"/>
            </Trigger>
            
        </Style.Triggers>
    </Style>
    
    <Style TargetType="{x:Type TextBlock}" x:Key="WrapText">
        <Setter Property="TextWrapping" Value="Wrap"/>
    </Style>

    <Style x:Key="DataCellStyle" TargetType="{x:Type DataGridCell}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Margin" Value="5 0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border Background="{TemplateBinding Background}" BorderThickness="0" SnapsToDevicePixels="True">
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DataStyle" TargetType="{x:Type DataGrid}">
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="#003b46"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="AutoGenerateColumns" Value="False" />
        <Setter Property="HeadersVisibility" Value="Column" />
        <Setter Property="Margin" Value="0 10 0 0" />
        <Setter Property="SelectionMode" Value="Single" />
        <Setter Property="SelectionUnit" Value="FullRow" />
        <Setter Property="CanUserAddRows" Value="False" />
        <Setter Property="CanUserDeleteRows" Value="False" />
        <Setter Property="CanUserReorderColumns" Value="False" />
        <Setter Property="CanUserResizeRows" Value="False" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="GridLinesVisibility" Value="None" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGrid}">
                    <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                        <ScrollViewer x:Name="ScrollViewer" Focusable="false">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Button Command="{x:Static DataGrid.SelectAllCommand}" Focusable="false" Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}}" 
                                                Visibility="{Binding HeadersVisibility, Converter={x:Static DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static DataGridHeadersVisibility.All}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" 
                                                Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                        <DataGridColumnHeadersPresenter x:Name="ColumnHeadersPresenter" Grid.Column="0" 
                                                                        Visibility="{Binding HeadersVisibility, Converter={x:Static DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                        <ScrollContentPresenter x:Name="ScrollContentPresenter" Grid.ColumnSpan="2" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.Row="1"/>
                                        <ScrollBar Margin="5" x:Name="VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}" Orientation="Vertical" Grid.Row="1" ViewportSize="{TemplateBinding ViewportHeight}" 
                                                   Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                                    </Grid>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsGrouping" Value="true"/>
                    <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
                </MultiTrigger.Conditions>
                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="HeaderStyle" TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Height" Value="50"/>
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="WhiteSmoke" />
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Border CornerRadius="10 10 0 0" Background="#003b46">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                  VerticalAlignment="Center" Margin="10"
                                                  RecognizesAccessKey="True"/>
                                <StackPanel Grid.Column="1" Orientation="Horizontal" Margin="5 0 0 0" >
                                    <Path Fill="Transparent"
                                          Stretch="Uniform"
                                          x:Name="SortUpIcon" Width="10"
                                          >
                                        <Path.Data>
                                            <PathGeometry
                                                Figures="M16 4.09375L15.28125 4.78125L6.78125 13.28125L8.21875 14.71875L15 7.9375L15 28L17 28L17 7.9375L23.78125 14.71875L25.21875 13.28125L16.71875 4.78125Z" />
                                        </Path.Data>
                                    </Path>
                                    <Path x:Name="SortDownIcon"
                                          Fill="Transparent"
                                          Stretch="Uniform"
                                          Width="10"
                                          Margin="0 0 5 0"
                                          >
                                        <Path.Data>
                                            <PathGeometry
                                                Figures="M15 4L15 24.085938L8.2070312 17.292969L6.7929688 18.707031L16 27.914062L25.207031 18.707031L23.792969 17.292969L17 24.085938L17 4L15 4 z" />
                                        </Path.Data>
                                    </Path>
                                </StackPanel>
                            </Grid>
                        </Border>
                        <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortDownIcon" Property="Fill" Value="WhiteSmoke"/>
                        </Trigger>

                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortUpIcon" Property="Fill" Value="WhiteSmoke"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Начальное окно, тут таблица изображена нормально, все видно

Увеличиваем на полный экран После возвращения в режим поменьше экран видим, что таблица справа не полностью видна, то есть она стала шире, хотя подразумевает, что должна вмещаться полностью


Ответы (0 шт):