开发者

WPF control with many GridViews

I have a WPF user control that will dynamically have any number of GridViews. Each is essentially the exact same except for the ItemsSource. Therefore each have the same columns and the same RowDetailsTemplate. To be specific what I am actually doing is settings the columns to the bound values and then setting the RowDetailsTemplate to the data template.

What is the best approach to essentially define the GridView once and copy it to all the others. I have tried 开发者_Go百科XamlWriter.Save with the GridView in the resources, but the columns and RowDetailsTemplate are not saved. I have also tried a style, but the columns property is not settable.

Maybe I did something wrong with the two approaches.


Use an ItemsControl with ItemTemplate. The DataTemplate used for the Itemtemplate should contain the GridView XAML with all the column definitions. Next bind the ItemsControl's ItemSource to a collection of whatever data object you want the GridViews to use as ItemSource.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜