bug fix
This commit is contained in:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user