WPF中的内容控制上的Pbm

编程入门 行业动态 更新时间:2024-10-28 07:26:10
本文介绍了WPF中的内容控制上的Pbm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨观众, 我以编程方式 设置属性 。 < contentcontrol width =130> 身高=130 Canvas.Top =150 Canvas.Left =470 Selector.IsSelected =True> 如何以编程方式设置此项。请设置此项我搜索了多个sites.still现在我没有回答。请让我清楚pbm.pls帮助我。

解决方案

你可以使用GetValue / SetValue()来连接DependencyProperty,避免直接调用属性for normal DependencyProperty

this .SetValue(Selector.IsSelectedProperty,真); 此 .GetValue(Selector.IsSelectedProperty) as bool ;

Selector.IsSelectedProperty是一个附加的DependencyProperty,作为附加属性,Selector定义了IsSelectedProperty和GetIsSelected( )/ SetIsSelected()方法。 如果是正常的DependencyProperty,例如高度属性,然后它定义了HeightProperty和Height属性(带有getter和setter)。 问候 Joseph Leung

Hi Viewers, I have a pbm on programatically set the property isselected=true in content control. <contentcontrol width="130"> Height="130" Canvas.Top="150" Canvas.Left="470" Selector.IsSelected="True"> How to set this programatically.Pls set this i searched many sites.still now i got no answer.pls let me clear the pbm.pls help me.

解决方案

You can use GetValue/SetValue() for attached DependencyProperty, avoid calling the property directly even for normal DependencyProperty

this.SetValue(Selector.IsSelectedProperty, true); this.GetValue(Selector.IsSelectedProperty) as bool;

Selector.IsSelectedProperty is a attached DependencyProperty, as an attached property, Selector defined both IsSelectedProperty and GetIsSelected()/SetIsSelected() method. If normal DependencyProperty, e.g. Height Property, then it defined the HeightProperty and "Height" property (with getter and setter). Regards Joseph Leung

更多推荐

WPF中的内容控制上的Pbm

本文发布于:2023-10-30 01:25:40,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内容   WPF   Pbm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!