Windows phone 7 将视图模型线集合数据绑定到画布(MVVM/Windows Phone)
我试图允许用户在点击和拖动时收集点,从而在画布上绘制。我使用的是MVVM方法,可以成功地收集点,并在视图模型上填充一组线。但是,我需要能够在画布上显示这些线条控件,以便用户可以看到他们正在绘制的线条Windows phone 7 将视图模型线集合数据绑定到画布(MVVM/Windows Phone),windows-phone-7,data-binding,mvvm,Windows Phone 7,Data Binding,Mvvm,我试图允许用户在点击和拖动时收集点,从而在画布上绘制。我使用的是MVVM方法,可以成功地收集点,并在视图模型上填充一组线。但是,我需要能够在画布上显示这些线条控件,以便用户可以看到他们正在绘制的线条 我的问题是,如何将线控件的视图模型集合数据绑定到画布的子集合?这可以通过使用项控件来实现: <ItemsControl ItemsSource="{Binding CollectionOfLines}"> <!-- specify the panel that the item
我的问题是,如何将线控件的视图模型集合数据绑定到画布的子集合?这可以通过使用
项控件来实现:
<ItemsControl ItemsSource="{Binding CollectionOfLines}">
<!-- specify the panel that the items will be added to -->
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Line X="{Binding ...}" Y="{Binding ...}" .../>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>