<UserControl x:Class="Aucma.Core.Palletiz.Views.PlanPageView" 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:local="clr-namespace:Aucma.Core.Palletiz.Views" mc:Ignorable="d" Background="#1152AC" d:DesignHeight="1080" d:DesignWidth="1920"> <UserControl.Resources> <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}"> <!--<Setter Property="Height" Value="40"/>--> <Setter Property="FontSize" Value="16"/> <Setter Property="VerticalAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Left" /> </Style> <Style TargetType="DataGrid"> <!--网格线颜色--> <Setter Property="CanUserResizeColumns" Value="false"/> <Setter Property="Background" Value="#1152AC" /> <Setter Property="BorderBrush" Value="#4285DE" /> <Setter Property="Foreground" Value="White"/> <Setter Property="HorizontalGridLinesBrush"> <Setter.Value> <SolidColorBrush Color="#4285DE"/> </Setter.Value> </Setter> <Setter Property="VerticalGridLinesBrush"> <Setter.Value> <SolidColorBrush Color="#1152AC"/> </Setter.Value> </Setter> </Style> <!--列头标题栏样式--> <Style TargetType="DataGridColumnHeader"> <!--<Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/>--> <!--<Setter Property="Background" Value="#dddddd"/> <Setter Property="Foreground" Value="Black"/>--> <!--<Setter Property="BorderThickness" Value="1" />--> <Setter Property="HorizontalContentAlignment" Value="Left" /> <Setter Property="BorderBrush" Value="#dddddd" /> <Setter Property="Height" Value="48"/> <Setter Property="FontSize" Value="18"/> <Setter Property="Background" Value="#4285DE"/> <Setter Property="Foreground" Value="White"/> </Style> <!--单元格样式--> <Style TargetType="DataGridCell"> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderBrush" Value="Gray" /> <Setter Property="Height" Value="40"/> <Setter Property="FontSize" Value="12"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridCell}"> <Grid Background="{TemplateBinding Background}" > <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="#4285DE"/> <Setter Property="Foreground" Value="White"/> </Trigger> </Style.Triggers> </Style> </UserControl.Resources> <Border x:Name="HeightHelperPanel" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="5"> <DataGrid x:Name="dgvMH" Height="{Binding Path=ActualHeight, ElementName=HeightPanel}" HorizontalAlignment="Left" VerticalAlignment="Top" AlternationCount="2" RowHeaderWidth="0" ItemsSource="{Binding Datalist}" ColumnWidth="*" AutoGenerateColumns="False" IsReadOnly="True" CanUserAddRows="False" SelectionMode="Single" SelectedItem="{Binding SelectedCells, Mode=OneWayToSource}"> <DataGrid.Columns> <DataGridTextColumn Width="*" Binding="{Binding OrderCode}" Header="编号" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Width="*" Binding="{Binding ProductCode}" Header="产品编码" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Width="*" Binding="{Binding ProductName}" Header="产品型号" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> </DataGrid.Columns> </DataGrid> </Border> </UserControl>