0

I've trying to create a navigation panel on the left of my app, I have several ListViews stacked on top of each other, with an invisible ToggleButton on the first item of each list. Then when these ToggleButtons are switched I want to trigger an event on the other ListViews.

I.e. change the height of all other ListViews to just view the first item; Setter TargetName="ClientItems" Property="Height" Value="40"

And also switch the value of the other ToggleButtons so only one or none ToggleButtons are checked. Setter TargetName="ClientsTglBtn" Value="ToggleButton.Checked"

<ToggleButton x:Name="ProjectsTglBtn"                                      
                Width="190"
                Height="40"
                VerticalAlignment="Top"
                BorderThickness="0"
                Background="Transparent"
                Style="{StaticResource ToggleButtonStyle}">
    <ToggleButton.Triggers>
        <EventTrigger RoutedEvent="ToggleButton.Unchecked">
            <BeginStoryboard>
                <Storyboard x:Name="HideProjectItems">
                    <DoubleAnimation
                            Storyboard.TargetName="ProjectItems"
                            Storyboard.TargetProperty="Height"
                            BeginTime="0:0:0:0"
                            From="160" To="40"
                            Duration="0:0:0:0.25">
                    </DoubleAnimation>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
        <EventTrigger RoutedEvent="ToggleButton.Checked">
            <Setter TargetName="ClientItems" Property="Height" Value="40"/>
            <Setter TargetName="ClientsTglBtn" Value="ToggleButton.Checked"/>
            <BeginStoryboard>
                <Storyboard x:Name="ShowProjectItems">
                    <DoubleAnimation
                            Storyboard.TargetName="ProjectItems"
                            Storyboard.TargetProperty="Height"
                            BeginTime="0:0:0:0"
                            From="40" To="160"
                            Duration="0:0:0:0.25">
                    </DoubleAnimation>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </ToggleButton.Triggers>
</ToggleButton>
5318008
  • 77
  • 5
  • You can use another discrete animation to set values (see e.g [here](https://stackoverflow.com/a/5495505/1997232) of how), but I'd rather look into MVVM and organize that switching on an abstract level somewhere in the view model/model. This way it would be eaiser to support. As well as using data templates to switch between various button sets. – Sinatr Jul 01 '21 at 13:15
  • Have you considered expanders? You want a togglebutton and you want it to expand it's content when checked. Sounds rather like an expander to me. Maybe re- templated. – Andy Jul 01 '21 at 14:03

0 Answers0