如何处理frozon control (WPF FAQ http://www.syncfusion.com/faq/wpf/default.aspx#60)
2008-10-20 15:22
603 查看
将一个control freeze后能够提高其性能。
If you try to modify a frozen Freezable object, it throws an 'Invalid Operation' Exception. To avoid throwing this exception, use the "IsFrozen" property of the Freezable object to determine whether it is frozen.
Button myButton = new Button();
SolidColorBrush myBrush = new SolidColorBrush(Colors.Yellow);
if (myBrush.CanFreeze)
{
// Makes the brush unmodifiable.
myBrush.Freeze();
}
myButton.Background = myBrush;
if (myBrush.IsFrozen) // Evaluates to true.
{
// If the brush is frozen, create a clone and
// modify the clone.
SolidColorBrush myBrushClone = myBrush.Clone();
myBrushClone.Color = Colors.Red;
myButton.Background = myBrushClone;
}
else
{
// If the brush is not frozen,
// it can be modified directly.
myBrush.Color = Colors.Red;
If you try to modify a frozen Freezable object, it throws an 'Invalid Operation' Exception. To avoid throwing this exception, use the "IsFrozen" property of the Freezable object to determine whether it is frozen.
Button myButton = new Button();
SolidColorBrush myBrush = new SolidColorBrush(Colors.Yellow);
if (myBrush.CanFreeze)
{
// Makes the brush unmodifiable.
myBrush.Freeze();
}
myButton.Background = myBrush;
if (myBrush.IsFrozen) // Evaluates to true.
{
// If the brush is frozen, create a clone and
// modify the clone.
SolidColorBrush myBrushClone = myBrush.Clone();
myBrushClone.Color = Colors.Red;
myButton.Background = myBrushClone;
}
else
{
// If the brush is not frozen,
// it can be modified directly.
myBrush.Color = Colors.Red;
相关文章推荐
- http://www.hanselman.com/blog/default.aspx
- 测试的url地址是http://www.QQView.com/testweb/default.aspx, 结果如下:
- http://www.sellsbrothers.com/writing/default.aspx?content=delegates.htm
- A nice gift from SQL Server 2005 SP2 to sync developers(转自http://blogs.msdn.com/synchronizer/default.aspx) - 江南白衣 - 博客园
- Socansoft net 代码生成器http://www.socansoft.com/Default.aspx
- A nice gift from SQL Server 2005 SP2 to sync developers(转自http://blogs.msdn.com/synchronizer/default.aspx)
- http://www.sympraxisconsulting.com/Demos/default.aspx spservice
- 评估期已过。有关如何升级的测试版软件的信息,请访问http://www.microsoft.com/sql/howtobuy
- 地图投影的选择--http://www.spbdev.com/Articles/ArticleRead.aspx?id=30
- 一个在线图形图像处理的网站:萝卜鼠在线图形图像处理 http://www.zpxp.com
- 罗校长指引我如何在GTalk Flash Version中输入中文! http://www.gtalkr.com
- http://www.microsoft.com/zh-cn/download/details.aspx?id=28358 silverlight tool 工具下载地址
- 该如何加载google-analytics(或其他第三方)的JS (转自http://www.cnblogs.com/BearsTaR/archive/2010/05/12/best_use_google_analytics.html)
- Redis到底该如何利用?【转自:http://www.cnblogs.com/capqueen/p/HowToUseRedis.html】
- http://www.pizzahut.com/Menu.aspx
- http://www.youtiy.com/Articles/Item.aspx?Id=291
- SqlServer Text类型字段超过8000字处理 http://www.cnblogs.com/birdshover/archive/2006/06/16/427303.html
- WPF企业内训全程实录(下) 转载 http://www.cnblogs.com/KnightsWarrior/archive/2010/12/09/1900832.html
- Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2013 http://www.microsoft.com/en-us/download/details.aspx?id=42313
- http://www.cnitblog.com/dotnetbbs/archive/2007/11/13/36223.aspx