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!"); } } }
分类:
wpf
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· Open-Sora 2.0 重磅开源!
2019-09-18 wpf button style IsMouseOver