女生与男生一起生产豆浆

核心内容摘要

雷电将军释怀网站:在永恒中寻找的,是那一刻的心动
18岁后的数字成人礼:开启属于年轻人的高阶内容宝库

天天弄细节之中见品质

案例一个ListBox绑定后台实体链表界面显示三个模块自定义模板实现顺序一般来说在C#的链表里从0开始我这里想让其从1开始使用了这种方法可以传递顺序到后台命令。

ListBox ItemContainerStyle{StaticResource ActionItemStyle} ItemsSource{Binding OverallActions} ScrollViewer.HorizontalScrollBarVisibilityDisabled ListBox.ItemTemplate DataTemplate Border Margin3 BorderThickness1 CornerRadius5 Grid Grid.ColumnDefinitions ColumnDefinition Width* / ColumnDefinition WidthAuto / ColumnDefinition WidthAuto / /Grid.ColumnDefinitions !-- 显示配置信息 -- StackPanel Grid.Column0 Margin10 TextBlock FontSize14 FontWeightBold Text{Binding ActionDescription} / /StackPanel !-- 索引显示 -- TextBlock Grid.Column1 Margin10 HorizontalAlignmentCenter VerticalAlignmentCenter FontSize16 FontWeightBold Text{Binding RelativeSource{RelativeSource AncestorType{x:Type ListBoxItem}}, Converter{StaticResource IndexConverter}} / !-- 操作按钮 -- StackPanel Grid.Column2 Margin10 OrientationHorizontal !-- 主操作按钮 -- Button Width60 Height30 Margin0,0,5,0 Command{Binding DataContext.ExecuteActionHandleModelCommand, RelativeSource{RelativeSource AncestorType{x:Type ListBox}}} CommandParameter{Binding RelativeSource{RelativeSource AncestorType{x:Type ListBoxItem}}, Converter{StaticResource IndexConverter}} Content执行 / /StackPanel /Grid /Border /DataTemplate /ListBox.ItemTemplate /ListBox传递参数CommandParameter{Binding RelativeSource{RelativeSource AncestorType{x:Type ListBoxItem}}, Converter{StaticResource IndexConverter}}绑定索引的转换器public class ItemToIndexConverter : IValueConverter { // 单值转换用于ListBoxItem/DataGridRow获取索引 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is ListBoxItem listBoxItem) { var listBox ItemsControl.ItemsControlFromItemContainer(listBoxItem); if (listBox ! null) { int index listBox.ItemContainerGenerator.IndexFromContainer(listBoxItem); return index 0 ? (index

.ToString() : N/A; } } else if (value is DataGridRow dataGridRow) { var dataGrid ItemsControl.ItemsControlFromItemContainer(dataGridRow); if (dataGrid ! null) { int index dataGrid.ItemContainerGenerator.IndexFromContainer(dataGridRow); return index 0 ? (index

.ToString() : N/A; } } return N/A; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }

92暗网-92暗网应用

百度百家号客服电话人工服务

123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123