How to make a control in XAML public in order to be seen in other classes

前端 未结 2 1983
粉色の甜心
粉色の甜心 2020-12-29 20:10

I\'m working in wpf application i made a checkbox in the XAML, then my code calls a function in a class and in this function there is an if condition where its checking on w

2条回答
  •  佛祖请我去吃肉
    2020-12-29 20:43

    Don't make the checkbox visible to the outside, just pass the current state of the checkbox to the function or class. Also consider binding the checkbox value to a class in the DataContext, directly accessing controls can be avoided most of the time in WPF, see also the MVVM pattern.

提交回复
热议问题