首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏dino.c的专栏

    创建包含CheckBox的ListBoxItem

    所以我使用这个方式封装了一个ListBox控件,目前基本上没什么功能,就只是在每个ListBoxItem前面加上一个CheckBox。 以前介绍过如何自定义ItemsControl,要自定义一个ListBox控件,同样需要三部: 定义ListBox 关联ListBoxItem和ListBox 实现ListBox的逻辑 public class ExtendedListBoxItem也模仿UWP提供了MultiSelectEnabled和MultiSelectDisabled两个VisualState,因为ListBoxItem需要知道承载它的 ) listBoxItem.Owner = this; } ListBoxItem中使用监视Owner的IsMultiSelectCheckBoxEnabled和SelectionMode 在ListBoxItem里用Trigger比使用VisualState更简洁有效。 4.

    4K20发布于 2020-02-21
  • 来自专栏林德熙的博客

    WPF 如何调试 binding

    ="Center" Text="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem : queried Grid (hash=64665535) System.Windows.Data Warning: 73 : Lookup ancestor of type ListBoxItem : queried Grid (hash=22098140) System.Windows.Data Warning: 73 : Lookup ancestor of type ListBoxItem : queried Grid (hash=42455531) System.Windows.Data Warning: 73 : Lookup ancestor of type ListBoxItem : queried Grid (hash=2598608) System.Windows.Data Warning: 73 : Lookup ancestor of type ListBoxItem

    1.5K10发布于 2018-09-18
  • 来自专栏dino.c的专栏

    [UWP 自定义控件]了解模板化控件(3):实现HeaderedContentControl

    <AutoSuggestBox Header="AutoSuggestBox" /> <TextBlock Text="ListBox" /> <ListBox> <ListBoxItem Content="ListBoxItem 1" /> <ListBoxItem Content="ListBoxItem 2" /> <ListBoxItem Content ="ListBoxItem 3" /> </ListBox> </StackPanel> ? Content="ListBoxItem 1" /> <ListBoxItem Content="ListBoxItem 2" /> <ListBoxItem Content="ListBoxItem 3" /> </ListBox> </local:HeaderedContentControl> </StackPanel> ?

    1.3K40发布于 2019-01-18
  • 来自专栏开心的平凡酱

    根据Expander的IsExpanded属性值的变化动态设计Control的size

                    <TabItem Header="HaHaTabItem" >                     <ListBox>                         <ListBoxItem Content="Blue" />                         <ListBoxItem Content="Black" />                         <ListBoxItem

    1.5K10发布于 2020-10-09
  • 来自专栏hbbliyong

    WPF Trigger for IsSelected in a DataTemplate for ListBox items

    I'd like to be able to set up the triggers in those files, looking at the ListBoxItem's IsSelected property The template to override the ListBoxItem follows: <Style TargetType="{x:Type <em>ListBoxItem</em>}"> Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type <em>ListBoxItem</em> DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem

    2.1K40发布于 2018-03-05
  • 来自专栏DotNet 致知

    XAML常用控件2

    以硬编码的形式填充数据,请看代码: <ListBox> <ListBoxItem>列表项1</ListBoxItem> <ListBoxItem>列表项2</ListBoxItem> <ListBoxItem>列表项3</ListBoxItem> <ListBoxItem>列表项4</ListBoxItem> <ListBoxItem>列表项5</ListBoxItem > </ListBox> 而且,ListBoxItem可以容纳控件,比如Button,CheckBox,都可以往里填充: <ListBox> <ListBoxItem> <Button Content="我是按钮"/> </ListBoxItem> <ListBoxItem> <CheckBox IsChecked="True"/> </ListBoxItem> </ListBox> 在这种情况下,ListBoxItem标签就可以省略了,系统会自动进行封装: <ListBox> <Button Content=

    3.3K30发布于 2021-11-05
  • 来自专栏JusterZhu

    WPF中对滚动条进行平滑滚动

     listBoxItem = list.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem; // 获取选择元素的位置 Point  position = listBoxItem.TranslatePoint(new Point(0, 0), list); //滚动到指定位置 this.scroll.ScrollToVerticalOffset 这种方案是可行的,示例代码如下 Random r = new Random(); var item = this.list.Items[r.Next(0, 50)]; ListBoxItem listBoxItem  = list.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem; // 获取选择元素的位置 Point position =  listBoxItem.TranslatePoint(new Point(0, 0), list); var gap = position.Y - this.scroll.VerticalOffset

    46300编辑于 2025-06-12
  • 来自专栏林德熙的博客

    WPF 鼠标移动到列表上 显示列表图标

    在列表新建一个图标,添加 Visibility Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem} Grid.ColumnDefinitions> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=<em>ListBoxItem</em> Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem ListView.ItemTemplate> </ListView> 获取当前列表项,使用{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem Grid.ColumnDefinitions> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=<em>ListBoxItem</em>

    2.4K20编辑于 2022-08-04
  • 来自专栏全栈程序员必看

    WPF中ListBox的WrapPanel布局「建议收藏」

    Width="100" Height="100" Margin="5" Content="1"/> <ListBoxItem Width="100" Height="100" Margin ="5" Content="2"/> <ListBoxItem Width="100" Height="100" Margin="5" Content="3"/> <ListBoxItem Width="100" Height="100" Margin="5" Content="4"/> <ListBoxItem Width="100" Height="100" Margin ="5" Content="5"/> <ListBoxItem Width="100" Height="100" Margin="5" Content="6"/> <ListBoxItem Width="100" Height="100" Margin="5" Content="7"/> <ListBoxItem Width="100" Height="100" Margin

    96020编辑于 2022-09-15
  • 来自专栏历史专栏

    【愚公系列】2023年09月 WPF控件专题 ListBox控件详解

    ListBoxItem:ListBox中每一个项都是一个ListBoxItem,可以通过定义ListBoxItem的样式来自定义ListBox的外观。 --<ListBoxItem Content="软件班" IsSelected="True" ></ListBoxItem> <ListBoxItem Content="数据班" ></ ListBoxItem> <ListBoxItem Content="英语班" ></ListBoxItem>--> </ListBox> </Grid> private void

    2.7K00编辑于 2023-09-29
  • 来自专栏ASP.NETCore

    WPF使ListBox支持手势多选功能

    在这个事件中我们可以得到我们所画出的形状的区域及 e.Strokes[0].GetGeometry(),然后我们对这ListBox的这个区域做命中检查VisualTreeHelper.HitTest,从中过滤出我们想选中的多个ListBoxItem <ListBox Name="listBox1" SelectionMode="Extended" Height="350" Width="780"> <ListBoxItem Content="Ok" /> <ListBoxItem Content="Maxzhang" /> <ListBoxItem Content="houxiaodong" /> <ListBoxItem Content="hao1" /> <ListBoxItem Content="wuhao" /> <ListBoxItem Content="xiaoge" /> <ListBoxItem

    98930发布于 2018-09-05
  • 来自专栏林德熙的博客

    WPF 鼠标移动到列表上 显示列表图标

    在列表新建一个图标,添加 Visibility Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem} Grid.ColumnDefinitions> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=<em>ListBoxItem</em> Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem 获取当前列表项,使用{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=(ItemsControl.AlternationIndex Grid.ColumnDefinitions> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=<em>ListBoxItem</em>

    3.3K10发布于 2018-09-18
  • 来自专栏菩提树下的杨过

    silverlight:ListBox中如何取得DateTemplate/ItemsPanelTemplate中的命名控件?

    = null)             {                 ListBoxItem _selectedItem = (ListBoxItem)(myListBox.ItemContainerGenerator.ContainerFromItem                 MessageBox.Show(string.Format("选中行的TextBlock值为:" + myTxt.Text));             }             ListBoxItem  _firstItem = (ListBoxItem)(myListBox.ItemContainerGenerator.ContainerFromItem(myListBox.Items[0])); null;         }     } public class TestData{public string d{set;get;}} } 这里我们借助VisualTreeHelper对指定行(ListBoxItem

    1.2K50发布于 2018-01-23
  • 来自专栏dino.c的专栏

    [UWP 自定义控件]了解模板化控件(6):使用附加属性

    </StackPanel> </Border> </ControlTemplate> </ListBox.Template> <ListBoxItem Content="ListBoxItem 1" /> <ListBoxItem Content="ListBoxItem 2" /> <ListBoxItem Content="ListBoxItem

    85330发布于 2019-01-18
  • 来自专栏walterlv - 吕毅的博客

    WPF 很少人知道的科技

    <CollectionContainer Collection="{Binding Source={StaticResource Items2Source}}" /> <ListBoxItem >Walterlv End Item 1</ListBoxItem> <ListBoxItem>Walterlv End Item 2</ListBoxItem>

    89120编辑于 2023-10-22
  • 来自专栏CSharp编程

    开源C# WPF控件库--Newbeecoder.UI使用指南(三)

    ListBoxItem用于填充每一项列表数据。 要选择一个ListBoxItem在列表框,设置IsSelected属性true。 默认情况下,的HorizontalAlignment一个的ListBoxItem的设置为拉伸。StackPanel的默认水平位置是Center。 如果您通过StackPanel设置ListBoxItem的Width属性,则应用面板的默认值并且项目居中。

    3K50编辑于 2022-05-05
  • 来自专栏码客

    WPF桌面端开发2-ItemsControl和ListBox获取点击行的索引

    { return new MyListBoxItem(); } } public class MyListBoxItem : ListBoxItem (dep is ListBoxItem)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } ListBoxItem item = (ListBoxItem)dep;

    3.5K30发布于 2020-05-09
  • 来自专栏dino.c的专栏

    [Silverlight]用ListBox实现SlideShow

                    </Setter.Value> 35            </Setter> 36        </Style> 37 38 39 40     <Style TargetType="<em>ListBoxItem</em> Property="Template"> 42                <Setter.Value> 43                    <ControlTemplate TargetType="<em>ListBoxItem</em>

    84430发布于 2019-01-18
  • 来自专栏Dotnet9

    WPF值得注意的IsHitTestVisible

    当然解决方案有很多: 可以写两个ListBoxItem的样式,第一个放顶部有渐变的背景,和右部保持一致,通过样式选择器来实现.这显然比较麻烦. 还可以在大背景下放个渐变,ListBoxItem的上半部分做成透明,这样相对简单,但不一定能实现理想的效果. IsHitTestVisible属性就很好的解决了这个问题.直接在上层放个border,背景设置成渐变,IsHitTestVisible设置为false.这样就既能看到渐变效果,又能透过border,直接点到ListBoxItem

    2.3K10发布于 2021-12-01
  • 来自专栏我和未来有约会

    silverlight beta 2 将在本周末发布.

    ToggleButton •       HyperlinkButton •       CheckBox •       RadioButton •       ListBox •       ListBoxItem •       Custom BorderBrush/BorderThickness Change •       ButtonBase Changes •       ListBox and ListBoxItem

    76460发布于 2018-01-16
领券