Silverlight DataGrid行背景分组着色

Silverlight DataGrid行背景分组着色,第1张

概述利用Silverlight DataGrid LoadingRow事件传入参数DataGridRowEventArgs 我们可以获取到Row对象She之其背景。 下面是一个简单示例 C# : using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Window

利用Silverlight DataGrID LoadingRow事件传入参数DataGrIDRowEventArgs

我们可以获取到Row对象She之其背景。

下面是一个简单示例

C#

using System;
System.Collections.Generic;
System.linq;
System.Net;
System.windows;
System.windows.Controls;
System.windows.documents;
System.windows.input;
System.windows.Media;
System.windows.Media.Animation;
System.windows.Shapes;

namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
MainPage()
{
InitializeComponent();
}

List
< SourceModel > grIDSources = new List ();

private voID UserControl_Loaded( object sender,RoutedEventArgs e)
{
}

LoadSource( int n)
{
if (n 1 )
throw Exception( " should >=1 " );
grIDSources.Clear();
for ( i 0 ; i n; i ++ )
{
grIDSources.Add(
SourceModel() { ID i.ToString(),name test + i,Group (( )( Random().NextDouble() * i)).ToString() });
}

j ;
grIDSources
grIDSources.OrderBy(t => t.Group).ToList();
grIDSources.GroupBy(t
t.Group).ToList().ForEach(t
{
t.ToList().ForEach(k
k.BG brushs[j % brushs.Length]);
j
;
});
}
Brush[] brushs
Brush[] { SolIDcolorBrush(color.FromArgb( 128 , 135 206 235 )), 255 240 140 97 )) };
test1_Click( grIDSources;
}

 
test2_Click( LoadSource_Click( .Parse( this .maxCount.Text));
}

dgSource_LoadingRow( (e.Row.DataContext as SourceModel).BG;
}
}

SourceModel
{
string ID { get ; set ; }
name { Group { Brush BG { ; }
}

}

XAMl:

< UserControl x:Class ="SilverlightApplication1.MainPage"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d
="http://schemas.microsoft.com/Expression/blend/2008"
xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable
="d"
xmlns:data
="clr-namespace:System.windows.Controls;assembly=System.windows.Controls.Data"
d:DesignHeight
="300" d:DesignWIDth ="400"
xmlns:i
="http://schemas.microsoft.com/Expression/2010/interactivity"
xmlns:sdk
="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:Test
="clr-namespace:SilverlightApplication1;assembly=SilverlightApplication1" > GrID x:name ="LayoutRoot" GrID.RowDeFinitions RowDeFinition ></ RowDeFinition RowDeFinition Height ="26" </ data:DataGrID GrID.Row ="0" x:name ="dgSource" margin ="3,3,3" RowBackground ="Black" autoGenerateColumns ="False" LoadingRow ="dgSource_LoadingRow" data:DataGrID.Columns data:DataGrIDTextColumn header ="ID" Binding =" {Binding ID} " IsReadonly ="True" /> ="name" {Binding name,Mode=TwoWay} ="Group" {Binding Group,0)">


data:DataGrID StackPanel OrIEntation ="Horizontal" GrID.Row ="1" TextBox ="maxCount" WIDth Text ="100000" TextBox button ="loadSource1" Click ="LoadSource_Click" Content ="Load Source" ="test1" ="test1_Click" ="Test bind" ="test2" ="test2_Click" ="Test 2" StackPanel GrID UserControl >

http://www.cnblogs.com/whitewolf/archive/2011/07/28/2119608.html

总结

以上是内存溢出为你收集整理的Silverlight DataGrid行背景分组着色全部内容,希望文章能够帮你解决Silverlight DataGrid行背景分组着色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1067522.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存