Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
2
Indexable
<Window x:Class="CollapsiblePanelExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Collapsible Panel Example" Height="450" Width="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/> <!-- Collapsible Panel Column -->
            <ColumnDefinition Width="*"/>    <!-- Tab Control Column -->
        </Grid.ColumnDefinitions>

        <!-- Collapsible Panel -->
        <Grid x:Name="CollapsiblePanel" Background="LightGray">
            <ToggleButton x:Name="CollapseButton" Content="Collapse/Expand"
                          HorizontalAlignment="Left" VerticalAlignment="Top"
                          Margin="5"/>
            <!-- Your Collapsible Panel Content Here -->
        </Grid>

        <!-- Tab Control -->
        <TabControl Grid.Column="1">
            <TabItem Header="Tab 1">
                <!-- Tab 1 Content -->
            </TabItem>
            <TabItem Header="Tab 2">
                <!-- Tab 2 Content -->
            </TabItem>
        </TabControl>
    </Grid>
</Window>


using System.Windows;

namespace CollapsiblePanelExample
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            
            // Event handler for CollapseButton's Click event
            CollapseButton.Click += (sender, e) =>
            {
                CollapsiblePanel.Visibility = 
                    CollapsiblePanel.Visibility == Visibility.Collapsed
                    ? Visibility.Visible : Visibility.Collapsed;
            };
        }
    }
}