I have a Grid
with StackPanel
objects.
The panel on the right has 4 vertical ToggleButton
objects.
The 4 respective StackPanel objects are using Binding for the Visbility. Example:
<StackPanel x:Name="panelMaterialAndSettings" Grid.Row="3" Background="WhiteSmoke" Margin="2"
Visibility="{Binding IsChecked, ElementName=buttonMaterialAndSettings, Converter={StaticResource BoolToVis}, FallbackValue=Collapsed}">
It works great. The problem I can't get my head around is the parent StackPanel
. That also needs to bind the Vibility property but it shoudl only return true if 1 or more of the 4 child panels are now visible.
I can do everything with manual behind code if I can't fix it.
Or, it could check the 4 ToggleButtons. But I am failing.
Markup:
<Grid Grid.Row="1" Grid.RowSpan="4" Grid.Column="2" Margin="2,0,2,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="panelExtraFeatures" Visibility="Collapsed" MinWidth="500" Grid.Column="0">
<StackPanel.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="{DynamicResource {x:Static SystemColors.AppWorkspaceColorKey}}" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="panelStudentPicker" Grid.Row="0" Background="WhiteSmoke" Margin="2,2,2,10" <StackPanel x:Name="panelStudentPicker" Grid.Row="0" Background="WhiteSmoke" Margin="2,2,2,10"
Visibility="{Binding IsChecked, ElementName=buttonStudentPicker, Converter={StaticResource BoolToVis}, FallbackValue=Collapsed}">
<Label Content="Student Picker" Background="LightSkyBlue" />
<Label>Panel 1</Label>
<Label>Panel 1</Label>
<Label>Panel 1</Label>
<Label>Panel 1</Label>
</StackPanel>
<StackPanel x:Name="panelDemonstrationPicker" Grid.Row="1" Background="WhiteSmoke" Margin="2,2,2,10"
Visibility="{Binding IsChecked, ElementName=buttonDemonstrationPicker, Converter={StaticResource BoolToVis}, FallbackValue=Collapsed}">
<Label Content="DemonStration Picker" Background="LightSkyBlue" />
<Label>Panel 2</Label>
<Label>Panel 2</Label>
<Label>Panel 2</Label>
<Label>Panel 2</Label>
</StackPanel>
<StackPanel x:Name="panelAssignmentHistory" Grid.Row="2" Background="WhiteSmoke" Margin="2,2,2,10"
Visibility="{Binding IsChecked, ElementName=buttonAssignmentHistory, Converter={StaticResource BoolToVis}, FallbackValue=Collapsed}">
<Label Content="Assignment History" Background="LightSkyBlue" />
<Label>Panel 3</Label>
<Label>Panel 3</Label>
<Label>Panel 3</Label>
<Label>Panel 3</Label>
</StackPanel>
<StackPanel x:Name="panelMaterialAndSettings" Grid.Row="3" Background="WhiteSmoke" Margin="2"
Visibility="{Binding IsChecked, ElementName=buttonMaterialAndSettings, Converter={StaticResource BoolToVis}, FallbackValue=Collapsed}">
<Label Content="Material and Settings" Background="LightSkyBlue" />
<GroupBox Header="Treasures From God's Word:" Margin="2">
<StackPanel HorizontalAlignment="Stretch">
<Label>Bible Reading:</Label>
<TextBox/>
</StackPanel>
</GroupBox>
<GroupBox Header="Apply Yourselves To The Field Ministry" Margin="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">Student Assignment #1:</Label>
<ComboBox Grid.Row="1" Grid.Column="0" IsEditable="True" SelectedIndex="0" Margin="2">
<ComboBoxItem Content="Initial Call"/>
<ComboBoxItem Content="Return Visit"/>
<ComboBoxItem Content="Bible Study"/>
</ComboBox>
<TextBox Grid.Row="1" Grid.Column="1"/>
<Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">Student Assignment #2:</Label>
<ComboBox Grid.Row="3" Grid.Column="0" IsEditable="True" SelectedIndex="1" Margin="2">
<ComboBoxItem Content="Initial Call"/>
<ComboBoxItem Content="Return Visit"/>
<ComboBoxItem Content="Bible Study"/>
</ComboBox>
<TextBox Grid.Row="3" Grid.Column="1"/>
<Label Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2">Student Assignment #3:</Label>
<ComboBox Grid.Row="5" Grid.Column="0" IsEditable="True" SelectedIndex="2" Margin="2">
<ComboBoxItem Content="Initial Call"/>
<ComboBoxItem Content="Return Visit"/>
<ComboBoxItem Content="Bible Study"/>
</ComboBox>
<TextBox Grid.Row="5" Grid.Column="1"/>
</Grid>
</GroupBox>
</StackPanel>
</Grid>
</StackPanel>
<StackPanel Grid.Column="1" Margin="2,0,2,2">
<StackPanel.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource {x:Static SystemColors.ActiveCaptionColorKey}}"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<ToggleButton x:Name="buttonStudentPicker" Content="Student Picker" HorizontalAlignment="Right" Margin="2,10,2,10" BorderThickness="0,5,0,0" Background="{x:Null}">
<ToggleButton.LayoutTransform>
<RotateTransform Angle="90"/>
</ToggleButton.LayoutTransform>
</ToggleButton>
<ToggleButton x:Name="buttonDemonstrationPicker" Content="Demonstrations Picker" HorizontalAlignment="Right" Margin="2,2,2,10" BorderThickness="0,5,0,0" Background="{x:Null}">
<ToggleButton.LayoutTransform>
<RotateTransform Angle="90"/>
</ToggleButton.LayoutTransform>
</ToggleButton>
<ToggleButton x:Name="buttonAssignmentHistory" Content="Assignment History" HorizontalAlignment="Right" Margin="2,2,2,10" BorderThickness="0,5,0,0" Background="{x:Null}">
<ToggleButton.LayoutTransform>
<RotateTransform Angle="90"/>
</ToggleButton.LayoutTransform>
</ToggleButton>
<ToggleButton x:Name="buttonMaterialAndSettings" Content="Material and Settings" HorizontalAlignment="Right" Margin="2" BorderThickness="0,5,0,0" Background="{x:Null}">
<ToggleButton.LayoutTransform>
<RotateTransform Angle="90"/>
</ToggleButton.LayoutTransform>
</ToggleButton>
</StackPanel>
</Grid>