基本信息
源码名称:wpf数据绑定示例源码下载
源码大小:0.02M
文件格式:.zip
开发语言:C#
更新时间:2013-10-03
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;
using System.ComponentModel;
namespace DataBindingLab
{
public partial class MainWindow : Window
{
CollectionViewSource listingDataView;
public MainWindow()
{
InitializeComponent();
listingDataView = (CollectionViewSource)(this.Resources["listingDataView"]);
}
private void OpenAddProductWindow(object sender, RoutedEventArgs e)
{
AddProductWindow addProductWindow = new AddProductWindow();
addProductWindow.ShowDialog();
}
private void ShowOnlyBargainsFilter(object sender, FilterEventArgs e)
{
AuctionItem product = e.Item as AuctionItem;
if (product != null)
{
// Filter out products with price 25 or above
if (product.CurrentPrice < 25)
{
e.Accepted = true;
}
else
{
e.Accepted = false;
}
}
}
private void AddGrouping(object sender, RoutedEventArgs args)
{
// This groups the items in the view by the property "Category"
PropertyGroupDescription groupDescription = new PropertyGroupDescription();
groupDescription.PropertyName = "Category";
listingDataView.GroupDescriptions.Add(groupDescription);
}
private void RemoveGrouping(object sender, RoutedEventArgs args)
{
listingDataView.GroupDescriptions.Clear();
}
private void AddSorting(object sender, RoutedEventArgs args)
{
// This sorts the items first by Category and within each Category,
// by StartDate. Notice that because Category is an enumeration,
// the order of the items is the same as in the enumeration declaration
listingDataView.SortDescriptions.Add(
new SortDescription("Category", ListSortDirection.Ascending));
listingDataView.SortDescriptions.Add(
new SortDescription("StartDate", ListSortDirection.Ascending));
}
private void RemoveSorting(object sender, RoutedEventArgs args)
{
listingDataView.SortDescriptions.Clear();
}
private void AddFiltering(object sender, RoutedEventArgs args)
{
listingDataView.Filter = new FilterEventHandler(ShowOnlyBargainsFilter);
}
private void RemoveFiltering(object sender, RoutedEventArgs args)
{
listingDataView.Filter -= new FilterEventHandler(ShowOnlyBargainsFilter);
}
}
}