开发者

WPF Pass current item from list to usercontrol

I am binding to an ObservableCollection<Stage> Stages as the ItemsSource for an ItemsControl:

<ItemsControl ItemsSource="{Binding Path=Stages}">

I开发者_JAVA技巧s there any way to pass the current stage object to a usercontrol in an item datatemplate like this:

<ItemsControl ItemsSource="{Binding Path=Stages}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:Stage}">
    <local:MyUserControl CustomDependencyProperty="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>

The real problem is I need to have the current Stage object to be a variable in MyUserControl to do some work on it. Passing it to the constructor [like: MyUserControl(Stage s)] seems like a good way of doing it but afaik there is no way to specify that in XAML. Any ideas?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜