WPF中的内容控制上的Pbm [英] Pbm on CONTENT CONTROL in WPF

查看:64
本文介绍了WPF中的内容控制上的Pbm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨观众,



我以编程方式 设置属性 isselected = true



< 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆