main
syneffort 2 years ago
parent 2d19b48778
commit 8fe7d30387
  1. 8
      PacticeSolution/MVVMButtonControl/MainWindow.xaml
  2. 2
      PacticeSolution/MVVMButtonControl/ViewModel/ModelViewMain.cs

@ -12,18 +12,18 @@
</Window.DataContext>
<StackPanel>
<Button Content="Add TextBox" Command="{Binding TestCommand}"/>
<ItemsControl x:Name="itcMain" ItemsSource="{Binding ButtonCollection}">
<Button x:Name="btnMain" Content="Add TextBox" Command="{Binding TestCommand}"/>
<ItemsControl x:Name="ctrMain" ItemsSource="{Binding ButtonCollection}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button x:Name="btnItem"
<Button x:Name="btnSub"
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}"
Command="{Binding ElementName=ctrMain, Path=DataContext.SubButtonCommand}"
CommandParameter="{Binding Name}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>

@ -52,7 +52,7 @@ namespace MVVMButtonControl.ViewModel
this.ButtonCollection[i].SelectedColor = Brushes.Transparent;
}
Buttons selected = this.ButtonCollection.Where(b => b.Name.Equals(parameter.ToString())).SingleOrDefault();
Buttons? selected = this.ButtonCollection.Where(b => b.Name.Equals(parameter.ToString())).SingleOrDefault();
if (selected == null)
return;

Loading…
Cancel
Save