WPF:ListView数据绑定及Style

DrugRecordsWin.xaml

<ListView Grid.Row="4" Grid.Column="1" Name="list_DrugDetails" Style="{StaticResource ListViewStyle}">
<ListView.View>
<GridView>

<!--列头style-->
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="GridViewColumnHeader">
<Setter Property="Background" Value="CadetBlue"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="25"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Padding" Value="5"/>
</Style>
</GridView.ColumnHeaderContainerStyle>

<!--列头数据及绑定-->

<GridViewColumn Header="药品Id" DisplayMemberBinding="{Binding Idm}"/>
<GridViewColumn Header="药品名称" DisplayMemberBinding="{Binding DrugName}"/>
<GridViewColumn Header="药品规格" DisplayMemberBinding="{Binding DrugSpec}"/>
<GridViewColumn Header="数量" DisplayMemberBinding="{Binding Quantity}"/>
<GridViewColumn Header="批次序号" DisplayMemberBinding="{Binding BatchXh}"/>
<GridViewColumn Header="批号" DisplayMemberBinding="{Binding BatchNo}"/>
</GridView>
</ListView.View>
</ListView>

DrugRecordsWin.xaml.cs

list_DrugDetails.ItemsSource=源

         /// <summary> 
        /// 双击list的某列时获取该列发要单的详细药品列表 
        /// </summary> 
        /// <param name="sender"></param> 
        /// <param name="e"></param> 
        private void list_BillDetails_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
        { 
            var drugDetails = list_BillDetails.SelectedItem as WPF_OPDrug.DataOP.OutBillInfor; 
            int xh = drugDetails.Xh; 
            list_DrugDetails.ItemsSource = dataOP.GetOPDrugOutBillDataByBillXh(xh); 
        }
 
上一篇:UOJ263 【NOIP2016】组合数问题


下一篇:LeetCode 503. 下一个更大元素 II(Next Greater Element II)