WPF效果第一百八十八篇之再玩Expander

大端午節的在屋里吹著空調擼著代碼真是酸爽47e62f025cc04d4e461cd765ba8e1c5c.png;閑話也不多扯,直接看今天要分享的效果:

25ba8e17eef07dfbe26d07a895a2d044.gif

1、關于簡單的布局設計:

473e41847db5b8bb3c4702a67bc7d750.png

2、前臺先來個死布局,回頭ListBox改模板:

<Expander ExpandDirection="Left" Header="控制卡" VerticalAlignment="Bottom" HorizontalAlignment="Right" Style="{StaticResource LeftExpanderStyle}"><StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Stretch"><Expander Header="信號分配卡" Style="{StaticResource ExpanderStyle}"><ListBox Style="{StaticResource FristListListBox}" ItemsSource="{Binding OneDataContext}" /></Expander><Expander Header="信號分配卡" Style="{StaticResource ExpanderStyle}"><ListBox Style="{StaticResource FristListListBox}" ItemsSource="{Binding TwoDataContext}" /></Expander><Expander Header="信號分配卡" Style="{StaticResource ExpanderStyle}"><ListBox Style="{StaticResource FristListListBox}" ItemsSource="{Binding ThreeDataContext}" /></Expander></StackPanel>
</Expander>

3、Expander的模板:

<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Expander}"><Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3" SnapsToDevicePixels="True"><Grid><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><ContentPresenter x:Name="ExpandSite" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="{TemplateBinding Padding}" Visibility="Collapsed" /><ToggleButton Grid.Column="1" x:Name="HeaderSite" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" DockPanel.Dock="Top" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" MinWidth="0" MinHeight="0" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" FocusVisualStyle="{x:Null}" VerticalAlignment="Bottom" HorizontalAlignment="Left" Height="40" /></Grid></Border></ControlTemplate></Setter.Value>
</Setter>

4、Expander的Left屬性觸發器:

<Trigger Property="ExpandDirection" Value="Left"><Setter Property="Style" TargetName="HeaderSite"><Setter.Value><Style TargetType="{x:Type ToggleButton}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ToggleButton}"><Border Padding="{TemplateBinding Padding}"><Grid Background="Transparent" SnapsToDevicePixels="False"><Border BorderBrush="#282BFF" BorderThickness="1" Padding="0"><WrapPanel VerticalAlignment="Center"><Path x:Name="arrow" Data="M0,0L8.5539884,0 17.246985,10.709991 17.32099,10.799011 17.359992,10.752991 21.637002,16.022003 17.359992,21.291992 8.6659879,32 0.11099243,32 9.9780006,19.847992 13.043004,16.069 12.970006,15.977997 9.8639869,12.153992z" SnapsToDevicePixels="False" Stroke="Transparent" StrokeThickness="0" Fill="White" Stretch="Uniform" Width="20" Height="20" /><CheckBox Margin="10,0,0,0" Content="{TemplateBinding Content}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" ContentStringFormat="{TemplateBinding ContentStringFormat}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" HorizontalAlignment="Center" VerticalAlignment="Center" /></WrapPanel></Border></Grid></Border><ControlTemplate.Triggers><Trigger Property="IsChecked" Value="True"><Setter Property="Data" TargetName="arrow" Value="M12.970992,0L21.524992,0 11.658996,12.152008 8.5930022,15.931 8.6660002,16.020996 11.772003,19.846008 21.636,32 13.082,32 4.3889922,21.290009 4.3150023,21.200989 4.2769927,21.247009 0,15.977997 4.2769927,10.708008z" /></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></Setter.Value></Setter>
</Trigger>

5、ListBox的ItemsPanel:

<ItemsPanelTemplate x:Key="FristItemsPanelTemplate"><VirtualizingStackPanel VerticalAlignment="Bottom" />
</ItemsPanelTemplate>

6、關于ListBoxItem的Template:

<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ListBoxItem}"><StackPanel Background="Transparent"><Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Height="60" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"><TextBlock Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="24" /></Border><Path Data="M13.002003,0L25.984006,13.004019 24.565005,14.420021 13.823991,3.6604153 13.823991,31.999021 11.818991,31.999021 11.818991,4.0220598 1.4180002,14.441021 0,13.025019z" Margin="0,10,0,0" Stretch="Fill" Fill="#FFFFFFFF" Width="26" Height="40" /></StackPanel></ControlTemplate></Setter.Value>
</Setter>

7、最后預告下一篇的效果:

6876cefcdb23f78ff1bff598ea865729.gif

最終簡單的效果先這樣吧e080a006364d7728a5fc0f8f9b4934d8.png;以后有時間的話,可以再去摸索一下更復雜的效果3e81ec538940a4627b88dfccac6673fa.png;編程不息、Bug不止、無Bug、無生活23a820094791eeb761268f9f6d93388c.png;改bug的冷靜、編碼的激情、完成后的喜悅、挖坑的激動 、填坑的興奮;這也許就是屌絲程序員的樂趣吧;今天就到這里吧;希望自己有動力一步一步堅持下去;生命不息,代碼不止;大家抽空可以看看今天分享的效果,有好的意見和想法,可以在留言板隨意留言;我看到后會第一時間回復大家,多謝大家的一直默默的關注和支持!如果覺得不錯,那就伸出您的小手點個贊并關注一下,多謝您的支持!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/286488.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/286488.shtml
英文地址,請注明出處:http://en.pswp.cn/news/286488.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Android之實現長按Webview頁面文字自定義復制、全選、分享、搜索、翻譯功能(支持多語言,博文也有Demo下載地址)

1 需求和效果爆照 瀏覽器app封裝了Webview,然后實現實現長按Webview頁面文字自定義復制、全選、分享、搜索、翻譯功能(支持多語言),都在自己的瀏覽器app里面進行搜索和翻譯,不跳到系統瀏覽器里面去 效果爆照如下,oppo手機效果如下 華為手機效果如下 2 Demo下載地址 De…

中國西北地區專題地圖合集(高清)

1. 西北地區概況圖 2. 西北地區植被類型分布圖 3. NDVI變化趨勢圖 4. 氣候與NDVI的相關性

Apache、tomcat、Nginx常用配置合集

配置文件地址&#xff1a; Apache&#xff1a; /etc/httpd/conf/httpd.conf tomcat&#xff1a; /usr/local/tomcat/conf/server.xml Nginx &#xff1a; /usr/local/nginx/conf/nginx.conf 開機啟動文件&#xff1a;/etc/rc.d/rc.local 啟動方式&#xff1a; Apache&#xff…

使用putty連接linux

使用putty連接linux 快照的使用 &#xff0c;做快照相當于做備份&#xff0c;比如配置好IP&#xff0c;快照一下&#xff0c;下次就可以在回到這里&#xff01; putty下載 最好去官網下載 下載putty.zip如圖所示 如何使用putty 如圖設置好IP然后 save 保存 如…

【WEB API項目實戰干貨系列】- API訪問客戶端(WebApiClient適用于MVC/WebForms/WinForm)(四)

目前最新的代碼已經通過Sqlite NHibernate Autofac滿足了我們基本的Demo需求. 按照既定的要求&#xff0c;我們的API會提供給眾多的客戶端使用, 這些客戶端可以是各種Web站點, APP, 或者是WinForm, WPF, Silverlight等諸如此類的應用&#xff0c;將來還有可能是各種Iot等物聯…

基于 Roslyn 實現代碼動態編譯

基于 Roslyn 實現代碼動態編譯Intro之前做的一個數據庫小工具可以支持根據 Model 代碼文件生成創建表的 sql 語句&#xff0c;原來是基于 CodeDom 實現的&#xff0c;后來改成使用基于 Roslyn 去做了。實現的原理在于編譯選擇的Model 文件生成一個程序集&#xff0c;再從這個程…

【GIS風暴】GIS拓撲關系原理詳解

目 錄 1. 拓撲關系的概念2. 拓撲元素3. 拓撲關系4. 拓撲關系的意義5. 拓撲在ArcGIS中實現1. 拓撲關系的概念 地圖上的拓撲關系是指圖形在保持連續狀態下的變形(縮放、旋轉和拉伸等),但圖形關系不變的性質。 2. 拓撲元素 對二維而言,矢量數據可抽象為點(節點)、線(鏈、…

Android之簡單的文件夾選擇器實現

1、效果爆照 2、代碼實現 前提需要保證app有讀寫權限 activity_select_folder.xml文件如下 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layo…

【iVX 初級工程師培訓教程 10篇文拿證】04 畫布及我和 iVX 合照

目錄 【iVX 初級工程師培訓教程 10篇文拿證】01 了解 iVX 完成新年賀卡 【iVX 初級工程師培訓教程 10篇文拿證】02 數值綁定及自適應網站制作 【iVX 初級工程師培訓教程 10篇文拿證】03 事件及猜數字小游戲 【iVX 初級工程師培訓教程 10篇文拿證】04 畫布及我和 iVX 合照 【iV…

360極速瀏覽器使用postman

步驟如下&#xff1a;1、將crx文件打包成zip文件2、解壓打包的zip文件&#xff0c;并將_metadata文件夾修改為metadata3、打開360瀏覽器的擴展4、360瀏覽器加載postman插件5、創建快捷方式6、雙擊快捷方式打開postman下載地址&#xff1a;http://pan.baidu.com/s/1c1ZX8XE如果網…

centos 下安裝man手冊

安裝centos minimal版本&#xff0c;發現沒有man手冊 需要安裝一下&#xff0c;yum install man-pages 本文轉自 XDATAPLUS 51CTO博客&#xff0c;原文鏈接:http://blog.51cto.com/xdataplus/1796126

# javascript 總結

# javascript 總結 ## 語法1. 區分大小寫2. 命名規范1. 首字母必須是 字母 _ $2. 其他字符可以是 數字 字母 下劃線 $3. 避開系統的關鍵字4. 單詞和單詞連接方式推薦駝峰命名3. 注釋1. 單行注釋 //注釋的內容2. 多行注釋 /*注釋內容*/4. 語句1. 要用;結尾(推薦做法)2. 如果不寫…

聊聊 C++ 和 C# 中的 lambda 玩法

這幾天在看 C 的 lambda 表達式&#xff0c;挺有意思&#xff0c;這個標準是在 C11標準 加進去的&#xff0c;也就是 2011 年&#xff0c;相比 C# 2007 還晚了個 4 年&#xff0c; Lambda 這東西非常好用&#xff0c;會上癮&#xff0c;今天我們簡單聊一聊。一&#xff1a;語法…

Android之網絡請求通過協程+okhttp的沒有做網絡異常處理導致程序奔潰問題

1 問題 app里面的網絡請求是通過協程+okhttp來實現的,但是沒有做網絡異常處理(域名無法解析、502錯誤等等一系列),導致程序奔潰 2 嘗試 因為app基本上做好了,外面有大幾十個地方調用,然后又有不同的作用域,調用的地方太多了,一開始修改在最外出的網絡請求地方直接加上…

Windows10系統重裝后必不可少的優化步驟

1. 查看系統的激活狀態 Win+R,打開運行,輸入slmgr.vbs -xpr,回車! 可以看到,該系統沒有永久激活,即將過期,過期后部分功能會不可使用,需要重新激活。 2. 徹底關掉Windows Defender 方法一: 打開“命令提示符(管理員)”,然后輸入: reg add "HKEY_LOCAL_MA…

【iVX 初級工程師培訓教程 10篇文拿證】03 事件及猜數字小游戲

目錄 【iVX 初級工程師培訓教程 10篇文拿證】01 了解 iVX 完成新年賀卡 【iVX 初級工程師培訓教程 10篇文拿證】02 數值綁定及自適應網站制作 【iVX 初級工程師培訓教程 10篇文拿證】03 事件及猜數字小游戲 【iVX 初級工程師培訓教程 10篇文拿證】04 畫布及我和 iVX 合照 【iV…

visual studio系列(vs)啟動調試網站使用ip+端口局域網訪問

vs系列工具創建web應用時會自動創建一些配置文件&#xff0c;本文章講的是如何修改配置文件&#xff0c;使vs在啟動運行調試情況下 使用ip端口形式在局域網訪問。本文章使用的是vs2015&#xff0c;.net 4.5。步驟如下&#xff1a;1.使用vs創建好你的web應用&#xff0c;打開項目…

Android studio之編譯提示Could not find :umeng-asms-v1.2.1:.

1 、問題 Could not determine the dependencies of task :app:compileDebugJavaWithJavac. > Could not resolve all task dependencies for configuration :app:debugCompileClasspath.> Could not find :umeng-asms-v1.2.1:.Required by:project :app> Could not …

1-100之間的奇數

#include "stdio.h" int main() {int i0;for(i1;i<100;i){if(i%21){printf("%d ",i);}}return 0; }轉載于:https://blog.51cto.com/zhangxinbei/1718010

計算機與操作系統基礎小結

計算機基礎概念 1946年二月美國&#xff0c;世界上第一臺電子計算機ENIAC誕生&#xff0c;似乎從這一年開始世界便逐漸變得不一樣了。隨著半個世紀的時間&#xff0c;計算機技術蓬勃發展&#xff0c;推動人類進入信息社會。 計算機操作界面&#xff1a; ①圖形用戶界面 ②命令行…