第一步:设计界面如下代码:
<Window x:Class="HRMSys.UI.SystemMgr.OperationLogWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="OperationLogWindow" Height="800" Width="600" Loaded="Window_Loaded"> <Grid> <DockPanel> <GroupBox Height="100" Header="搜索条件" DockPanel.Dock="Top"> <Grid> <CheckBox Content="操作员" Height="16" HorizontalAlignment="Left" Margin="6,6,0,0" Name="cbSearchByOperator" VerticalAlignment="Top" /> <CheckBox Content="操作日期" Height="16" HorizontalAlignment="Left" Margin="198,6,0,0" Name="cbSearchByMakeDate" VerticalAlignment="Top" /> <CheckBox Content="操作描述" Height="16" HorizontalAlignment="Left" Margin="11,45,0,0" Name="cbSearchByAction" VerticalAlignment="Top" /> <ComboBox DisplayMemberPath="UserName" SelectedValuePath="Id" Height="23" HorizontalAlignment="Left" Margin="72,6,0,0" Name="cmbOperator" VerticalAlignment="Top" Width="106" /> <DatePicker Height="25" HorizontalAlignment="Left" Margin="272,4,0,0" Name="dpBeginDate" VerticalAlignment="Top" Width="115" /> <DatePicker Height="25" HorizontalAlignment="Left" Margin="445,4,0,0" Name="dpEndDate" VerticalAlignment="Top" Width="115" /> <TextBlock Height="23" HorizontalAlignment="Left" Margin="398,5,0,0" Name="textBlock1" Text="到" VerticalAlignment="Top" /> <TextBox Height="23" HorizontalAlignment="Left" Margin="95,38,0,0" Name="txtAcionDesc" VerticalAlignment="Top" Width="120" /> <Button Content="搜索" Height="23" HorizontalAlignment="Left" Margin="264,38,0,0" Name="btnSearch" VerticalAlignment="Top" Width="75" Click="btnSearch_Click" /> </Grid> </GroupBox> <DataGrid DockPanel.Dock="Top" Name="datagrid" IsReadOnly="True" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridComboBoxColumn Header="操作员" SelectedValueBinding="{Binding OperatorId}" SelectedValuePath="Id" DisplayMemberPath="UserName" x:Name="colOperator"></DataGridComboBoxColumn> <DataGridTextColumn Header="日期" Binding="{Binding MakeDate}"></DataGridTextColumn> <DataGridTextColumn Header="说明" Binding="{Binding ActionDesc}"></DataGridTextColumn> </DataGrid.Columns> </DataGrid> </DockPanel> </Grid> </Window>