当前位置: 首页 > news >正文

织梦程序来搭建网站网站制作企业首页

织梦程序来搭建网站,网站制作企业首页,网页设计师主要是做什么,网站开发需要哪些人才将集合绑定到ItemsControl控件时#xff0c;会不加通告的在后台创建数据视图——位于数据源和绑定的控件之间。数据视图是进入数据源的窗口#xff0c;可以跟踪当前项#xff0c;并且支持各种功能#xff0c;如排序、过滤、分组。 这些功能和数据对象本身是相互独立的会不加通告的在后台创建数据视图——位于数据源和绑定的控件之间。数据视图是进入数据源的窗口可以跟踪当前项并且支持各种功能如排序、过滤、分组。 这些功能和数据对象本身是相互独立的这意味着可在窗口的不同部分使用不同的方式绑定相同的数据。例如可将同一个集合绑定到两个不同的列表并对集合进行过滤以显示不同的记录。来自于WPF编程宝典。我实测下来绑定自同一个数据源的ItemsControl控件会共享一个View当对该View进行筛选、排序时会应用到所有绑定到该数据源的控件。 获取视图的方法 ListCollectionView? view CollectionViewSource.GetDefaultView(filterListBox.ItemsSource) as ListCollectionView; ListCollectionView? view CollectionViewSource.GetDefaultView(Orders) as ListCollectionView;可以看到可以直接通过数据源来获取视图这也表明绑定到同一个数据源的控件会公用一个视图。 视图有 MoveCurrentToPrevious()、MoveCurrentToNext() 方法可以用于视图导航。 private void cmdPrev_Click(object sender, RoutedEventArgs e){View?.MoveCurrentToPrevious();}private void cmdNext_Click(object sender, RoutedEventArgs e){View?.MoveCurrentToNext();}private void view_CurrentChanged(object? sender, EventArgs e){lblPosition.Text Record (View?.CurrentPosition 1).ToString() of View?.Count.ToString();cmdPrev.IsEnabled View?.CurrentPosition 0;cmdNext.IsEnabled View?.CurrentPosition View?.Count - 1;} 视图排序 View.SortDescriptions.Add(new SortDescription(Volume, ListSortDirection.Ascending)); View.SortDescriptions.Add(new SortDescription(Price, ListSortDirection.Descending)); 视图分组 ListBox x:NamegroupListBox ItemsSource{Binding PathOrders}ListBox.ItemTemplateDataTemplateTextBlockTextBlock Text{Binding Price}/TextBlock - TextBlock Text{Binding Volume}/TextBlock/TextBlock/DataTemplate/ListBox.ItemTemplateListBox.GroupStyleGroupStyleGroupStyle.HeaderTemplateDataTemplateTextBlock Text{Binding PathName} FontWeightBold ForegroundWhite BackgroundLightGreen Margin0,5,0,0 Padding3//DataTemplate/GroupStyle.HeaderTemplate/GroupStyle/ListBox.GroupStyle /ListBox View.GroupDescriptions.Add(new PropertyGroupDescription(Volume)); 视图过滤 public class ProductByPriceFilterer {public ProductByPriceFilterer(decimal minimumPrice){MinimumPrice minimumPrice;}public decimal MinimumPrice { get; set; }public bool FilterItem(Object item){Order? order item as Order;if (order ! null){return order.Price MinimumPrice;}return false;} } public partial class MainWindow : Window {public MainWindow(){InitializeComponent();View (ListCollectionView)CollectionViewSource.GetDefaultView(Orders);View.IsLiveFiltering true;View.LiveFilteringProperties.Add(Price);}public ObservableCollectionOrder Orders { get; set; } new();private ListCollectionView? View;public decimal MinPrice { get; set; } 200;private ProductByPriceFilterer? filterer;private void cmdFilter_Click(object sender, RoutedEventArgs e){if (View ! null){filterer new ProductByPriceFilterer(MinPrice);View.Filter new Predicateobject(filterer.FilterItem);}}private void cmdRemoveFilter_Click(object sender, RoutedEventArgs e){if (View ! null){View.Filter null;}} } 完整代码文件 MainWindow.xaml Window x:ClassDataView.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:DataViewmc:IgnorabledTitleMainWindow Height450 Width800Grid NamemyGridGrid.ColumnDefinitionsColumnDefinition/ColumnDefinition//Grid.ColumnDefinitionsGrid.RowDefinitionsRowDefinition/RowDefinition/RowDefinition/RowDefinition HeightAuto//Grid.RowDefinitionsStackPanel Grid.Row0 Grid.Column0 StackPanel OrientationHorizontalButton NamecmdPrev ClickcmdPrev_Clicklt;/ButtonTextBlock NamelblPosition VerticalAlignmentCenter/TextBlockButton NamecmdNext ClickcmdNext_Clickgt;/Button/StackPanelListBox x:NamenavigateListBox DisplayMemberPathPrice IsSynchronizedWithCurrentItemTrue ItemsSource{Binding PathOrders}//StackPanelStackPanel Grid.Row0 Grid.Column1 HorizontalAlignmentStretch VerticalAlignmentStretchGridGrid.ColumnDefinitionsColumnDefinition/ColumnDefinitionColumnDefinition/ColumnDefinition/Grid.ColumnDefinitionsGrid.RowDefinitionsRowDefinition/RowDefinitionRowDefinition/RowDefinition/Grid.RowDefinitionsLabel Grid.Row0 Grid.Column0Price Than/LabelTextBox Grid.Row0 Grid.Column1 Text{Binding PathMinPrice}/TextBoxButton Grid.Row1 Grid.Column0 ClickcmdFilter_ClickFilter/ButtonButton Grid.Row1 Grid.Column1 ClickcmdRemoveFilter_ClickRemove Filter/Button/GridListBox NamefilterListBox DisplayMemberPathPrice ItemsSource{Binding PathOrders}//StackPanelStackPanel Grid.Row1 Grid.Column0ListBox x:NamegroupListBox ItemsSource{Binding PathOrders}ListBox.ItemTemplateDataTemplateTextBlockTextBlock Text{Binding Price}/TextBlock - TextBlock Text{Binding Volume}/TextBlock/TextBlock/DataTemplate/ListBox.ItemTemplateListBox.GroupStyleGroupStyleGroupStyle.HeaderTemplateDataTemplateTextBlock Text{Binding PathName} FontWeightBold ForegroundWhite BackgroundLightGreen Margin0,5,0,0 Padding3//DataTemplate/GroupStyle.HeaderTemplate/GroupStyle/ListBox.GroupStyle/ListBox/StackPanelButton Grid.Row2 Grid.Column0 ContentIncrease Price ClickIncreaseButton_Click/Button Grid.Row2 Grid.Column1 ContentDecrease Price ClickDecreaseButton_Click//Grid /WindowMainWindow.xaml.cs using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Globalization; using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Controls; using System.Windows.Data;namespace DataView;public class ViewModelBase : INotifyPropertyChanged {public event PropertyChangedEventHandler? PropertyChanged;protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName null){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));}protected virtual bool SetPropertyT(ref T member, T value, [CallerMemberName] string? propertyName null){if (EqualityComparerT.Default.Equals(member, value)){return false;}member value;OnPropertyChanged(propertyName);return true;} } public class Order : ViewModelBase {public decimal price 0;public decimal Price { get price; set SetProperty(ref price, value); }public int volume 0;public int Volume { get volume; set SetProperty(ref volume, value); }public DateTime orderDate DateTime.Now;public DateTime OrderDate { get orderDate; set SetProperty(ref orderDate, value); }public string image string.Empty;public string Image { get image; set SetProperty(ref image, value); } } public class ProductByPriceFilterer {public ProductByPriceFilterer(decimal minimumPrice){MinimumPrice minimumPrice;}public decimal MinimumPrice { get; set; }public bool FilterItem(Object item){Order? order item as Order;if (order ! null){return order.Price MinimumPrice;}return false;} } public class PriceRangeProductGrouper : IValueConverter {public int GroupInterval { get; set; }public object Convert(object value, Type targetType, object parameter, CultureInfo culture){decimal price (decimal)value;if (price GroupInterval){return string.Format(Less than {0:C}, GroupInterval);}else{int interval (int)price / GroupInterval;int lowerLimit interval * GroupInterval;int upperLimit (interval 1) * GroupInterval;return string.Format({0:C} to {1:C}, lowerLimit, upperLimit);}}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotSupportedException(This converter is for grouping only.);} } public partial class MainWindow : Window {public MainWindow(){InitializeComponent();myGrid.DataContext this;InitOrders();InitView();}public void InitOrders(){Order order1 new Order();Order order2 new Order();Order order3 new Order();Order order4 new Order();order1.Price 100;order1.Volume 100;order1.Image image1.gif;order2.Price 1000;order2.Volume 100;order2.Image image2.gif;order3.Price 10000;order3.Volume 10000;order3.Image image3.gif;order4.Price 100000;order4.Volume 10000;order4.Image image4.gif;Orders.Add(order1);Orders.Add(order2);Orders.Add(order3);Orders.Add(order4);}private void InitView(){View (ListCollectionView)CollectionViewSource.GetDefaultView(Orders);if(View ! null){View.CurrentChanged new EventHandler(view_CurrentChanged);View.SortDescriptions.Add(new SortDescription(Volume, ListSortDirection.Ascending));View.SortDescriptions.Add(new SortDescription(Price, ListSortDirection.Descending));View.GroupDescriptions.Add(new PropertyGroupDescription(Volume));View.IsLiveFiltering true;View.LiveFilteringProperties.Add(Price);}}public ObservableCollectionOrder Orders { get; set; } new();private ListCollectionView? View;private void cmdPrev_Click(object sender, RoutedEventArgs e){View?.MoveCurrentToPrevious();}private void cmdNext_Click(object sender, RoutedEventArgs e){View?.MoveCurrentToNext();}private void view_CurrentChanged(object? sender, EventArgs e){lblPosition.Text Record (View?.CurrentPosition 1).ToString() of View?.Count.ToString();cmdPrev.IsEnabled View?.CurrentPosition 0;cmdNext.IsEnabled View?.CurrentPosition View?.Count - 1;}public decimal MinPrice { get; set; } 200;private ProductByPriceFilterer? filterer;private void cmdFilter_Click(object sender, RoutedEventArgs e){if (View ! null){filterer new ProductByPriceFilterer(MinPrice);View.Filter new Predicateobject(filterer.FilterItem);}}private void cmdRemoveFilter_Click(object sender, RoutedEventArgs e){if (View ! null){View.Filter null;}}private void IncreaseButton_Click(object sender, RoutedEventArgs e){foreach(var order in Orders){order.Price * 10;}}private void DecreaseButton_Click(object sender, RoutedEventArgs e){foreach (var order in Orders){order.Price / 10;}} }
http://www.tj-hxxt.cn/news/224402.html

相关文章:

  • 家具网站建设策划方案价格网如何查产品价格
  • 上海网站建设制作微信营销型 网站建设流程
  • 网站建站历史wordpress主题the7中文汉化版
  • 南宁网站建设王道下拉強邮箱域名是什么
  • 旅游类网站设计模板下载专业网站制作公司排行
  • 网站建设 收费网站外链建设是什么
  • 建设厅网站上怎么实名认证网页建设哪里最便宜
  • 企业网站模板建设电商的运营推广
  • 佛山市和城乡建设局网站首页常州如何进行网站推广
  • 老外做中文网站网站组件
  • 新民个人网站建设优势快速搭建网站视频
  • 应该符合建设网站网站备案几天
  • 企业网站建设方案书范本网站开发济南招聘
  • 做印刷的有什么网站公司网站维护工作内容
  • 河南县公司网站建设网站开发费用成本表
  • eclipse可以做网站吗永州网站seo
  • 已有网站开发安卓app青岛关键词排名系统
  • wordpress更新文章未找到页面seo免费资源大全
  • 推广网站代码南京华夏天成建设有限公司网站
  • 建设厅网站上的信息采集表网站跳出率因素
  • 蓝希菏泽网站建设做公司网站都需要什么
  • 海宁市住房和城乡建设网站网页制作创建站点
  • 郑州网站建设案例wordpress如何添加页面子目录下
  • 网站建设属于移动互联网德宏企业网站建设公司6
  • 企业网站搭建程序广州外贸网站设计
  • 西樵网站设计制作做网站最下面写什么
  • 广西建设厅考试网站首页数字营销传播
  • 长春网站建设公司怎么样购物网站建设模板下载
  • 长春 万网 网站建设苏州网站设计公司有哪些
  • 用drupal做的网站淘宝评价采集wordpress