开发者

WPF bind to a list

I have a user control whose users I want to have them set a DataContext on to bind to a list of objects. In my control, however, I want to display that list in a Grid, but in a non-trivial order. The column/row of display of each element will be determined by some code I will write.

So I cannot do a straight databinding in my control, I need to write code that will read the DataContext and then do the processing to correctly position each element.

How would a relative WPF newbie go about doing that? I guess the part I don't understand is 开发者_开发问答what the code in my usercontrol will look like to read the DataContext items so that I can process them.

EDIT: Clarification: I want to stress I want to bind to the XAML Grid element, not some other kind of grid or DataGrid. Thx!


One of the possible way to achieve that is to use a Converter. You could create a Converter which converts the input list into another list where the order has been changed. Then you could use a "normal" databinding which will use the Converter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜