WPF Expander ExpandDirection Left,Right,Up,Down,IsExpanded property,Expanded and Collapsed event
//xaml <Window x:Class="WpfApp378.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp378" mc:Ignorable="d" WindowState="Maximized" Title="MainWindow" Height="450" Width="800"> <Grid ShowGridLines="True"> <Grid.ColumnDefinitions> <ColumnDefinition Width="500"/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Expander Header="Gramma Left" IsExpanded="True" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed" ExpandDirection="Left" Grid.Column="0" Grid.Row="0"> <StackPanel> <CheckBox>Check gramma as you type.</CheckBox> <CheckBox>Hide grammatical errors in this document.</CheckBox> <CheckBox>Check gramma with spelling.</CheckBox> </StackPanel> </Expander> <Expander Header="Gramma Right" ExpandDirection="Right" Grid.Column="0" Grid.Row="1"> <StackPanel> <CheckBox>Check gramma as you type.</CheckBox> <CheckBox>Hide grammatical errors in this document.</CheckBox> <CheckBox>Check gramma with spelling.</CheckBox> </StackPanel> </Expander> <Expander Header="Gramma Down" ExpandDirection="Down" Grid.Column="0" Grid.Row="2"> <StackPanel> <CheckBox>Check gramma as you type.</CheckBox> <CheckBox>Hide grammatical errors in this document.</CheckBox> <CheckBox>Check gramma with spelling.</CheckBox> </StackPanel> </Expander> <Expander Header="Gramma Up" ExpandDirection="Up" Grid.Column="0" Grid.Row="3"> <StackPanel> <CheckBox>Check gramma as you type.</CheckBox> <CheckBox>Hide grammatical errors in this document.</CheckBox> <CheckBox>Check gramma with spelling.</CheckBox> </StackPanel> </Expander> </Grid> </Window> //cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApp378 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); //SuppressScriptErrors(webBrowser, true); } void SuppressScriptErrors(WebBrowser browser, bool hide) { browser.Navigating += (s, e) => { var fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (fiComWebBrowser == null) { return; } object objComBrowser = fiComWebBrowser.GetValue(browser); if (objComBrowser == null) { return; } objComBrowser.GetType().InvokeMember("Silent", System.Reflection.BindingFlags.SetProperty, null, objComBrowser, new object[] { hide }); }; } private void Expander_Expanded(object sender, RoutedEventArgs e) { MessageBox.Show("Expander will Left Expand!"); } private void Expander_Collapsed(object sender, RoutedEventArgs e) { MessageBox.Show("Expander will Left Collapse!"); } } }