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

    关于我的知识盲区之ItemsSource的分享~

    一、为何说它是知识盲区呢 1、首先很多人应该都和我一样知道itemsSource,在 Windows 应用程序中很多控件都提供了 DataSource 属性,并将 DataSet 或 DataTable 下面有一个例子,我们可以看到,初始化界面的时候,数据绑定了一次(mygard.ItemsSource),当点击按钮的时候,itemsource的值就发生改变了,这个是为什么呢? true, Email = new Uri("mailto:Lucy@school.com") }); mygard.ItemsSource

    1.6K20发布于 2020-06-19
  • 来自专栏独立观察员博客

    【编辑】解决 Wpf TabControl 在所有选项卡上仅创建一个视图 的问题

    如何为每个选项卡创建单独的 ListView,但同时使用 ItemsSource 属性? = GetCachedItemsSource(tc); if (itemsSource == null || itemsSource.Count == null) { = GetCachedItemsSource(tabControl); if (itemsSource == null || itemsSource.Count == 0) = GetCachedItemsSource(tabControl); if(itemsSource == null || itemsSource.Count == 0) = itemsSource[i]) { current.DataContext = itemsSource[i];

    2.6K10编辑于 2024-11-23
  • 来自专栏Kiba518

    【我们一起写框架】MVVM的WPF框架(三)—数据控件

    ; public ObservableCollection<T> ItemsSource { get { return _ItemsSource ; } set { _ItemsSource = value; if (_ItemsSource ! = null && _ItemsSource.Count > 0 && SelectedItem == null) { SelectedItem = _ItemsSource.First(); } OnPropertyChanged(); } } public T _ ObservableCollection:我们可以看到ItemsSource是类型是ObservableCollection,而不是List。为什么要用ObservableCollection呢?

    3.5K30发布于 2018-09-28
  • 来自专栏个人编程笔记

    C#-DataGridComboBoxColumn数据绑定

    如果直接在DataGridComboBoxColumn上使用ItemsSource会发现没有作用,有几种解决方式,一种就是不要使用DataGridComboBoxColumn,使用DataGridTemplateColumn DataGridComboBoxColumn.EditingElementStyle> <Style TargetType="Combobox"> <Setter Property="<em>ItemsSource</em> Style TargetType="Combobox"> <Style TargetType="Combobox"> <Setter Property="<em>ItemsSource</em> 参考;wpf – Problem binding DataGridComboBoxColumn.<em>ItemsSource</em> – Stack Overflow 第三种方式采用静态资源进行绑定,参考代码: <Window.Resources TestList}"> </CollectionViewSource> </Window.Resources> <DataGridComboBoxColumn Header="测试绑定" ItemsSource

    96920编辑于 2023-11-03
  • 来自专栏全栈程序员必看

    treeview控件使用详解python_TreeView控件实践

    HierarchicalDataTemplate用来支持HeaderedItemsControl,其中DataType指定当前的数据类型, 只有符合这个类型才使用HierarchicalDataTemplate;ItemsSource ItemsSource = “{Binding Path=Divisions}”> 2)对于TreeView控件, 我们可以只指定一个HierarchicalDataTemplate, 而保证数据结构每层的 schemas.microsoft.com/winfx/2006/xaml” Title=”HierarchicalDataTemplate Sample” xmlns:src=”clr-namespace:SDKSample”> ItemsSource = “{Binding Path=Divisions}”> ItemsSource = “{Binding Path=Teams}”> ItemsSource=”{Binding Source={StaticResource

    1.4K20编辑于 2022-11-04
  • 来自专栏czwy的博客

    [WPF]原生TabControl控件实现拖拽排序功能

    从代码中可以看到列表控件的ItemsSource不能为空,否则拖拽无效。这也是后边将提到的一个缺点。 = null) this.ItemUnderDragCursor = null; e.Effects = DragDropEffects.None; var itemsSource = this.selector.ItemsSource; if (itemsSource == null) return; int itemsCount = 0; Type type = null; foreach (object obj in itemsSource) { type = obj.GetType(); itemsCount ProcessDropEventArgs args = new ProcessDropEventArgs(itemsSource, data, oldIndex, newIndex, e.AllowedEffects

    1.2K20编辑于 2023-10-26
  • 来自专栏dino.c的专栏

    [Silverlight]简单实现DataGrid使用CheckBox选择行

    在DataGrid.Columns中加入自定义的Column,然后在代码中关联DataGrid和这个Colum,就完成了: <sdk:DataGrid ItemsSource="{Binding}"                        = null)             {                 var enu = _ownerDataGrid.ItemsSource.GetEnumerator();                          }         public void SetSelectedItems(IList items)         {             if (_ownerDataGrid.ItemsSource  == null)                 return;             var enu = _ownerDataGrid.ItemsSource.GetEnumerator();  == null)                 return;             var enu = _ownerDataGrid.ItemsSource.GetEnumerator();

    1.3K30发布于 2019-01-18
  • 来自专栏独立观察员博客

    WPF 实现扇形统计图

    typeof(SectorChart), new PropertyMetadata(null)); public ObservableCollection<PieSerise> ItemsSource public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource ItemsSource.Any() || _canvas is null) return; _canvas.Children.Clear(); (ser => ser.Percentage).Sum(); foreach (var item in ItemsSource) { xmlns:wsCharts="https://github.com/WPFDevelopersOrg.WPFDevelopers.Charts" <wsCharts:SectorChart ItemsSource

    1.8K10编辑于 2022-12-06
  • 来自专栏dotNET编程大全

    C# WPF mvvm模式下combobox绑定(list<enum>、Dictionary<int,string>)

    ComboBox是一个非常常用的界面控件,它的数据源ItemsSource既可以绑定一个List列表,也可以是一个字典,本篇文章就讲这些内容展开讲解。 01 — 前言 ComboBox是一个非常常用的下拉菜单界面控件,它的数据源ItemsSource既可以绑定一个List列表,也可以是一个字典,本篇文章就讲这些内容展开讲解。 SelectedIndex="2" DisplayMemberPath="Name" ItemsSource HorizontalAlignment="Left" SelectedIndex="0" ItemsSource DisplayMemberPath="Value" SelectedValuePath="Key" ItemsSource

    8.1K10发布于 2021-11-01
  • 来自专栏Kiba518

    【我们一起写框架】MVVM的WPF框架(四)—DataGrid

    get { return _ItemsSource; } set { _ItemsSource = value; if (_ItemsSource ! = _ItemsSource.First(); } OnPropertyChanged(); } Xaml页面代码如下: <DataGrid Margin="5" FontSize="12" ItemsSource="{Binding TestDataGrid.ItemsSource}" AutoGenerateColumns ="{Binding TestDataGrid.ItemsSource}" AutoGenerateColumns="True" SelectedItem=

    1.8K20发布于 2018-10-12
  • 来自专栏林德熙的博客

    WPF 多线程下跨线程处理 ObservableCollection 数据

    如果 ObservableCollection 被 UI 元素捕获,例如加入到 ItemsSource 里面,那么此时的 ObservableCollection 不仅只能被单一线程处理,还要求这个线程是 先在后台线程创建 ObservableCollection 对象,然后在后台线程完成处理逻辑,最后赋值给 ListView 的 ItemsSource 属性,实现更新界面逻辑 private async 然后再赋值给 ListView 的 ItemsSource 属性 上面代码符合了上文说的逻辑条件,首先 ObservableCollection 非线程安全,单一的时刻,只有一个线程进行访问。 接下来进入 ListView.ItemsSource = list 也就是将 list 交给 UI 线程,在此单一的时刻,也只有 UI 线程,一个线程在访问 在将 ObservableCollection 只有在调用 ListView.ItemsSource = list 代码之后,才将 ObservableCollection 关联到 UI 线程。

    5.1K10编辑于 2022-08-12
  • 来自专栏林德熙的博客

    WPF 列表控件数据源绑定多个数据集合方法

    CollectionViewSource x:Key="CatCollection" Source="{Binding Cats}"/> </ListBox.Resources> <ListBox.ItemsSource ="{Binding Source={StaticResource CatCollection}}"/> </CompositeCollection> </ListBox.ItemsSource 就是集合控件,此方法需要用到 x:Reference 获取对象的引用,同时需要通过 DataContext 的某个属性获取到对应的属性,全部代码如下 <ListBox x:Name="MyList" ItemsSource 但不足的地方在于绑定 ItemsSource 需要用到 DynamicResource 的方式,相对性能不如上面方法。为什么需要 DynamicResource 资源? Reference Root}}"/> </CompositeCollection> </Window.Resources> <Grid> <ListBox x:Name="MyList" ItemsSource

    4.6K21发布于 2021-05-27
  • 来自专栏哲学驱动设计

    WPF 中 ICollectionView 及 ItemsControl 相关的重点

    它的使用方法简单地说有两种:一种是使用 ItemsSource + ItemTemplate 来进行数据绑定;一种是直接使用 Items 属性来添加或者删除元素,这种使用方法和在 WinForm 下的使用方案比较类似 也就是说,Items 其实是 ItemsSource 属性的视图集合类,我们可以通过这个属性来设置 ItemsControl 中集合的显示方案(Filter、Sorting、Grouping、Current 当 ItemsSource 存在时,_collectionView 字段是 CollectionViewSource.GetDefaultView 来为 ItemsSource 找到它所对应的 CollectionView 而当我们没有设置 ItemsSource 属性而是直接使用 Items 属性集合时,ItemsCollection 则会生成一个 InnerItemCollectionView 类的对象。    

    2.2K60发布于 2018-01-29
  • 来自专栏CSharp编程大全

    C# WPF控件ComboBoxEdit数据绑定及模糊匹配

    HumanSkinList.Add(HumanSkinColor); } } step5:绑定数据源到控件 ComboBoxCtr.ItemsSource ; } if (HumanSkinList.Count > 0) { ComboBoxCtr.ItemsSource (object sender, RoutedEventArgs e) { BindingEnumData(); ComboBoxCtr.ItemsSource ; } if (HumanSkinList.Count > 0) { ComboBoxCtr.ItemsSource

    2.6K20编辑于 2021-12-06
  • 来自专栏czwy的博客

    WPF中非递归(无后台代码)动态实现TreeView

    通过ItemsSource属性查找下一层级的数据集合,并将它提供给第二层模板。这样描述可能有点晦涩。接下来举例进行描述。 首先假设一个应用场景。 <HierarchicalDataTemplate DataType="{x:Type local:School}" ItemsSource="{Binding Path=listGrade}"> SchoolName}" /> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type local:Grade}" ItemsSource GradeName}" /> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type local:ClassInfo}" ItemsSource <TreeView MaxHeight="480" ItemsSource="{Binding schools}" VirtualizingPanel.IsVirtualizing

    1K40编辑于 2023-10-22
  • 来自专栏林德熙的博客

    WPF 省市县3级联动

    ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <ComboBox Grid.Column="0" ItemsSource Province,Mode=TwoWay}"> </ComboBox> <ComboBox Grid.Column="1" x:Name="ComboBoxCity" ItemsSource Binding Path=City,Mode=TwoWay}" ></ComboBox> <ComboBox Grid.Column="2" x:Name="ComboBoxCounty" ItemsSource SelectedValuePath="Id" SelectedValue="{Binding Path=County,Mode=TwoWay}"></ComboBox> </Grid> 可以看到ItemsSource

    2.5K20发布于 2018-09-19
  • 来自专栏林德熙的博客

    WPF 省市县3级联动

    ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <ComboBox Grid.Column="0" ItemsSource Province,Mode=TwoWay}"> </ComboBox> <ComboBox Grid.Column="1" x:Name="ComboBoxCity" ItemsSource Binding Path=City,Mode=TwoWay}" ></ComboBox> <ComboBox Grid.Column="2" x:Name="ComboBoxCounty" ItemsSource SelectedValuePath="Id" SelectedValue="{Binding Path=County,Mode=TwoWay}"></ComboBox> </Grid> 可以看到ItemsSource

    1.6K20编辑于 2022-08-04
  • 来自专栏DotNet NB && CloudNative

    WPF/C#:如何显示具有层级关系的数据

    class2 }; DataContext = classes; } 数据模板的使用 xaml: <TreeView> <TreeViewItem ItemsSource 通常,您会在ItemsSource属性中指定数据源,然后使用HierarchicalDataTemplate定义每个级别的数据对象应该如何呈现。 的使用 xaml: <Window.Resources> <HierarchicalDataTemplate DataType = "{x:Type local2:Class}" ItemsSource Path=Name}"/> </DataTemplate> </Window.Resources> 我们可以发现对于Class类,使用了一个HierarchicalDataTemplate,ItemsSource

    1.3K10编辑于 2024-05-09
  • 来自专栏历史专栏

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

    以下是ComboBox控件的一些常见属性和用法: 绑定数据源:可以将ComboBox控件绑定到一个数据源,使用ItemsSource属性指定数据源。 下面是一个简单的ComboBox控件的例子: <ComboBox ItemsSource="{Binding MyItemsSource}" DisplayMemberPath=" 1.属性介绍 WPF中ComboBox控件有以下常用属性: ItemsSource:设置ComboBox中显示的项的数据源。 SelectedItem:获取或设置ComboBox中选中项的对象。 //cboClasses.ItemsSource = null; //list.Add(new ClassInfo() //{ // ClassId = 4, // ClassName = "软件班" //}); //cboClasses.ItemsSource = list;

    3.6K20编辑于 2023-10-01
  • 来自专栏dino.c的专栏

    [WPF] 使用 HandyControl 的 CirclePanel 画出表盘刻度

    使用 CirclePanel 实现 既然要用 ItemsControl,那首先要有个集合作为它的 ItemsSource。 :String>Sam Hobbs</sys:String> </x:Array> 不过也可以不这么大费周章,在 .NET 中 string 也是一个集合, 可以用作 ItemsControl 的 ItemsSource 但在 Xaml 上直接写 ItemsSource="somestring"` 会报错,可以用 ContentControl 包装一下,写成这样: <ContentControl Content="111111111111 "> <ContentControl.ContentTemplate> <DataTemplate> <ItemsControl ItemsSource= 首先改变 ItemsSource 的内容,让它变成 60 个指针。

    2.3K30编辑于 2022-09-27
领券