<UserControl x:Class="BPASmartClient.MorkCL.View.Test" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BPASmartClient.MorkCL.View" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel" Name="测试" d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> <UserControl.DataContext> <vm:testViewModel /> </UserControl.DataContext> <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/BPASmartClient.MorkCL;component/CustomStyle/CustomStyle.xaml" /> </ResourceDictionary.MergedDictionaries> <Style TargetType="DataGridCell"> <Setter Property="FontSize" Value="16" /> <Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="Foreground" Value="{StaticResource FontColor}" /> <Setter Property="BorderBrush" Value="{StaticResource bordColor}" /> </Style> <Style TargetType="DataGridColumnHeader"> <Setter Property="FontSize" Value="22" /> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="Foreground" Value="{StaticResource FontColor}" /> <Setter Property="BorderBrush" Value="{StaticResource TitleBorderColor}" /> <Setter Property="BorderThickness" Value="1" /> </Style> </ResourceDictionary> </UserControl.Resources> <StackPanel Orientation="Vertical"> <Button Width="100" Height="30" Command="{Binding testCommand}" Content="Init" /> <ListView Height="100" ItemsSource="{Binding TBS}"> <ListView.View> <GridView> <GridView.Columns> <GridViewColumn Width="200"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Id}" /> </DataTemplate> </GridViewColumn.CellTemplate> <GridViewColumnHeader HorizontalContentAlignment="Center" Content="ID" IsHitTestVisible="False" /> </GridViewColumn> <GridViewColumn Width="200"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" /> </DataTemplate> </GridViewColumn.CellTemplate> <GridViewColumnHeader HorizontalContentAlignment="Center" Content="Name" IsHitTestVisible="False" /> </GridViewColumn> <GridViewColumn Width="Auto"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Description}" /> </DataTemplate> </GridViewColumn.CellTemplate> <GridViewColumnHeader HorizontalContentAlignment="Center" Content="描述" IsHitTestVisible="False" /> </GridViewColumn> <GridViewColumn Width="200"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Loc}" /> </DataTemplate> </GridViewColumn.CellTemplate> <GridViewColumnHeader HorizontalContentAlignment="Center" Content="位置" IsHitTestVisible="False" /> </GridViewColumn> </GridView.Columns> </GridView> </ListView.View> </ListView> <DataGrid Height="500" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" IsHitTestVisible="False" IsReadOnly="True" ItemsSource="{Binding TBS}" RowHeaderWidth="0"> <DataGrid.Columns> <DataGridTextColumn Width="350" Binding="{Binding Id}" Header="ID" /> <DataGridTextColumn Width="70" Binding="{Binding Name}" Header="名称" /> <DataGridTextColumn Width="*" Binding="{Binding Description}" Header="描述" /> <DataGridTextColumn Width="100" Binding="{Binding Loc}" Header="位置" /> </DataGrid.Columns> </DataGrid> </StackPanel> </UserControl>