学习下WPF,顺便用WPF把WinForm的程序改成了WPF,功能和MFC版功能基本相同
主要代码:
1 设置DataGrid的Style
<Style x:Key="Body_Content_DataGrid_Centering" TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="ForestGreen"/>
</Trigger>
</Style.Triggers>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="FontSize" Value="13" />
</Style>
<DataGrid Grid.Row="0" Name="dgHashInfo"
AutoGenerateColumns="False"
HeadersVisibility="All" RowHeaderWidth="18" RowHeight="25"
SelectionMode="Extended"
SelectionUnit="FullRow"
CanUserSortColumns="False"
CanUserResizeRows="False"
CanUserAddRows="False"
AllowDrop="True"
DragEnter="dgHashInfo_DragEnter"
DragOver="dgHashInfo_DragEnter"
Drop="dgHashInfo_Drop"
LoadingRow="dgHashInfo_LoadingRow"
CellStyle="{StaticResource Body_Content_DataGrid_Centering}"
ItemsSource="{Binding}" >
<DataGrid.RowStyle>