【发布时间】:2011-06-27 03:55:51
【问题描述】:
以下是场景:我有一个 flickr 照片查看器,PhotoBrowserViewModel 有一个名为 Image Source 的属性。绑定到我的 PhotoBrowserViewModel 的视图包含以下 XAML。 我的目标是让子控件具有 ImageSource 属性的高度/宽度。
<ItemsControl ItemsSource="{Binding Photos}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="viewmodel:FlickrPhotoViewModel">
<controls:FlickrPhotoControl Margin="10"/>
<!-- I want to set this control's Width/Height to {Binding PhotoSize}-->
<!-- on the same data context as ItemsControl, not as the data template.-->
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
【问题讨论】: