简体   繁体   English

在绑定到xaml对象属性的属性设置器中执行exec私有功能合法吗?

[英]It is legal to exec private function in property setter which is bind to xaml object property?

Assume that I Have RadioButton in xaml. 假设我在xaml中有RadioButton。

//...
IsChecked="{Binding A}"
//...

Now somewhere in code I have: 现在在代码中的某处我有:

private bool a; 
public bool A 
{ 
    get { return a; }
    set { a = value; foo(); }
}

I'am asking because when I add function foo() to setter then xaml preview changes look in strange way... 我问是因为当我将foo()函数添加到setter时,xaml预览更改看起来很奇怪。

// I'm not very familiar with C# so if it is not a problem in general to do something like that I will try to find other cause. //我对C#不太熟悉,因此,如果一般来说做这样的事情不是问题,我将尝试寻找其他原因。 So far I don't found it is legal but maybe it is obvious for every else :) 到目前为止,我还不认为这是合法的,但对于其他所有人来说,这也许都是显而易见的:)

foo is checking value of A (and other values similar to A, other RadioButtons) and editing list which is not correlated to any other code so far foo正在检查A的值(以及其他类似于A的值,其他RadioButtons)和编辑列表,到目前为止,该列表与任何其他代码均不相关

Yes! 是! The answer is: Make sure that this list is not null and that you remembered to initialize it! 答案是:确保此列表不为空,并且您记得对其进行了初始化!

No null exception, no any other message just 'strange' difference in xaml and no action in running app. 没有null异常,没有任何其他消息只是xaml中的“奇怪”差异,并且在运行的应用程序中没有任何动作。

Sorry everyone :) 对不起大家:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM