简体   繁体   中英

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

Assume that I Have RadioButton in xaml.

//...
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...

// 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. 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

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.

Sorry everyone :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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