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.

32 lines
1.5 KiB

<Window x:Class="MVVMButtonControl.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:MVVMButtonControl" xmlns:viewmodel="clr-namespace:MVVMButtonControl.ViewModel"
mc:Ignorable="d"
Title="MainWindow" Height="300" Width="200">
<Window.DataContext>
<viewmodel:ModelViewMain/>
</Window.DataContext>
<StackPanel>
<Button Content="Add TextBox" Command="{Binding TestCommand}"/>
<ItemsControl x:Name="itcMain" ItemsSource="{Binding ButtonCollection}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button x:Name="btnItem"
Content="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
FontWeight="Bold"
FontSize="18"
Margin="10"
Width="100"
Background="{Binding SelectedColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Command="{Binding ElementName=itcMain, Path=SubCommandMethod}"
CommandParameter="{Binding Name}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Window>