I would like to create window when in left panel is menu (with toggle buttons) and in right panel are views. When I click in toggle button, visible the view and another views will be hidden. But my code do open view despite himself. This is my code:
<StackPanel Grid.Column="0">
<ToggleButton Name="Button1" Checked="MenuItem_Checked">
<ToggleButton Name="Button2" Checked="MenuItem_Checked">
</StackPanel>
<administration:View1 Grid.Column="1"
Visibility="{Binding ElementName=Button1, Path=IsChecked, UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource BooleanToVisibilityConverter}}"/>
<administration:View2 Grid.Column="1"
Visibility="{Binding ElementName=Button2, Path=IsChecked, UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource BooleanToVisibilityConverter}}"/>
Code Behind:
private void MenuItem_Checked(object sender, RoutedEventArgs e)
{
var el = sender as ToggleButton;
if (Equals(_current, el))
return;
_current = el;
foreach (var menuChild in Menu.Children)
{
ToggleButton button = menuChild as ToggleButton;
if (button == null) continue;
if (!Equals(button, _current))
button.IsChecked = false;
}
}
This is my solution: