私はビューを持っています:
<Grid>
<Canvas Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" x:Name="ImageHolder">
<!-- there is something to do here !!! -->
<!-- like
<ImageCollection>
<DataTemplate For One Image>
<Image Canvas.Left="{Binding Path=posX}"
Canvas.Top="{Binding Path=posY}"
Source="{Binding Path=fileName}"
x:Name="{Binding Path=fileName}"
MouseDown="Img_MouseDown"
MouseUp="Img_MouseUp" />
</DataTemplate For One Image>
</ImageCollection> -->
</Canvas>
</Grid>
そして.csです
public partial class WindowBoard : Window
{
protected MyCollectionVM _myCollection; // this class inherits of INotifyPropertyChanged
public WindowBoard()
{
InitializeComponent();
_myCollection = new MyCollectionVM();
}
}
ViewModelClass で dataBinding を使用するために、この XAML に動的に画像を追加します。
つまり、1 つの dataTemplate イメージで userControl を作成する方法を知っていますが、多くのイメージでは動的に追加されます。
リストビューでそれを行う方法は知っていますが、キャンバスでそれを行う方法がわかりません.gridView/gridviewCellTemplateなどはありません...