开发者

How to get WPF window controls collection

I try to get all 开发者_开发知识库WPF window controls collections. In other words i try to get the same result, as it was in win forms app's:

form.Controls

I want to use values of these controlls when i format an SQL query. It's possible to get such control collection of WPF window? Thanks


Can I suggest that you stop thinking in terms of retrieving from the UI? You're using WPF which has an incredibly powerful databinding subsystem, so think in terms of retrieving from the model instead. If you read up on MVVM (Model View ViewModel), you'll see why you should be looking at the data instead, and how easy it is to do.


Use LogicalTreeHelper.GetChildren(window). Recurse as required. Also see VisualTreeHelper.


You can use Me.gr1.Children, where gr1 is grid on your windows, just don't forget to name it as x:Name="gr1"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜