You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<Window x:Class="MVVMCanvasRectangle.MainWindow"
|
|
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
|
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
|
|
xmlns:local="clr-namespace:MVVMCanvasRectangle" xmlns:viewmodel="clr-namespace:MVVMCanvasRectangle.ViewModel"
|
|
|
|
|
mc:Ignorable="d"
|
|
|
|
|
Title="MainWindow" Height="200" Width="600">
|
|
|
|
|
|
|
|
|
|
<Window.DataContext>
|
|
|
|
|
<viewmodel:RectModelView/>
|
|
|
|
|
</Window.DataContext>
|
|
|
|
|
|
|
|
|
|
<StackPanel>
|
|
|
|
|
<TextBox x:Name="txtCount" HorizontalAlignment="Center" Margin="5" Width="100" Text="{Binding Count, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
|
|
|
|
|
<ItemsControl x:Name="itcMain" ItemsSource="{Binding RectItems}" Height="150" Margin="5">
|
|
|
|
|
<ItemsControl.ItemsPanel>
|
|
|
|
|
<ItemsPanelTemplate>
|
|
|
|
|
<Canvas/>
|
|
|
|
|
</ItemsPanelTemplate>
|
|
|
|
|
</ItemsControl.ItemsPanel>
|
|
|
|
|
<ItemsControl.ItemContainerStyle>
|
|
|
|
|
<Style TargetType="ContentPresenter">
|
|
|
|
|
<Setter Property="Canvas.Left" Value="{Binding X}"/>
|
|
|
|
|
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
|
|
|
|
|
</Style>
|
|
|
|
|
</ItemsControl.ItemContainerStyle>
|
|
|
|
|
<ItemsControl.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<Rectangle Width="{Binding Width}" Height="{Binding Height}" Fill="LightCoral"/>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ItemsControl.ItemTemplate>
|
|
|
|
|
</ItemsControl>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Window>
|