喵盒社区:不止是次元壁破,更是心之所向的温暖港湾

核心内容摘要

520886com视频:高清无码,解锁你的视界新维度
王多鱼的牌局:一场关于选择与命运的智慧博弈

墨染芳华,步履生香:当“麻辣教师”遇上黑色双开真丝旗袍,尽显东方极致韵致

案例一个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(); } }

蜜豆直播-蜜豆直播应用

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

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