Bind StackPanel.Visibility to the Visibility property of its children

后端 未结 2 701
半阙折子戏
半阙折子戏 2021-01-13 12:47

I\'m relatively new to DataBinding and just reading into it. What I want to do is the following:

I have a StackPanel with a number of child controls:



        
2条回答
  •  -上瘾入骨i
    2021-01-13 13:21

    I can not think of a way to do this directly through databinding.

    Personally I would have a view model behind the view, and set the views DataContext to the view model.

    In the view model I would then have a property telling the view if all the textboxes are collapsed. That property would be set by code. Then bind the stackpanel visibility to that property.

    (The property must either be a dependancy property, or the view model must implement INotifyPropertyChanged for the view to automatically update)

提交回复
热议问题