当前位置: 首页 > news >正文

C# Avalonia 17- ControlTemplates - MultiPartTemplates

MultiPartTemplates.axaml代码

<Window xmlns="https://github.com/avaloniaui"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"Height="239" Width="248"x:Class="AvaloniaUI.MultiPartTemplates"Title="MultiPartTemplates"><Window.Resources><!-- ===== 基础画刷定义 ===== --><SolidColorBrush x:Key="StandardBorderBrush" Color="#888" /><SolidColorBrush x:Key="StandardBackgroundBrush" Color="#FFF" /><SolidColorBrush x:Key="HoverBorderBrush" Color="#DDD" /><SolidColorBrush x:Key="SelectedBackgroundBrush" Color="Blue" /><SolidColorBrush x:Key="SelectedForegroundBrush" Color="White" /><SolidColorBrush x:Key="GlyphBrush" Color="#444" /><LinearGradientBrush x:Key="ListBoxBackgroundBrush" StartPoint="0,0" EndPoint="1,0.001"><GradientStop Offset="0.0" Color="White" /><GradientStop Offset="0.6" Color="White" /><GradientStop Offset="1.2" Color="#DDDDDD" /></LinearGradientBrush><LinearGradientBrush x:Key="StandardBrush" StartPoint="0,0" EndPoint="0,1"><GradientStop Offset="0.0" Color="#FFF" /><GradientStop Offset="1.0" Color="#CCC" /></LinearGradientBrush><LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1"><GradientStop Offset="0.0" Color="#BBB" /><GradientStop Offset="0.1" Color="#EEE" /><GradientStop Offset="0.9" Color="#EEE" /><GradientStop Offset="1.0" Color="#FFF" /></LinearGradientBrush></Window.Resources><Window.Styles><!-- ========== ListBox 样式 ========== --><Style Selector="ListBox"><Setter Property="Background" Value="{StaticResource StandardBackgroundBrush}"/><Setter Property="BorderBrush" Value="{StaticResource StandardBorderBrush}"/><Setter Property="BorderThickness" Value="1"/><Setter Property="CornerRadius" Value="3"/><Setter Property="Padding" Value="2"/><Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/><Setter Property="Template"><ControlTemplate><Border Background="{TemplateBinding Background}"BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"CornerRadius="{TemplateBinding CornerRadius}"><ScrollViewer Focusable="False"><ItemsPresenter Margin="{TemplateBinding Padding}"/></ScrollViewer></Border></ControlTemplate></Setter></Style><!-- ========== ListBoxItem 样式 ========== --><Style Selector="ListBoxItem"><Setter Property="Padding" Value="4,2"/><Setter Property="CornerRadius" Value="3"/><Setter Property="Background" Value="Transparent"/><Setter Property="BorderBrush" Value="Transparent"/><Setter Property="BorderThickness" Value="2"/><Setter Property="Transitions"><Transitions><DoubleTransition Property="FontSize" Duration="0:0:0.2"/><BrushTransition Property="Background" Duration="0:0:0.2"/></Transitions></Setter><Setter Property="Template"><ControlTemplate><Border Name="Border"BorderThickness="{TemplateBinding BorderThickness}"BorderBrush="{TemplateBinding BorderBrush}"Background="{TemplateBinding Background}"CornerRadius="{TemplateBinding CornerRadius}"Padding="{TemplateBinding Padding}"><ContentPresenter Content="{TemplateBinding Content}"ContentTemplate="{TemplateBinding ContentTemplate}"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/></Border></ControlTemplate></Setter><!-- 鼠标Hover状态 --><Style Selector="^:pointerover"><Setter Property="BorderBrush" Value="{StaticResource HoverBorderBrush}"/><Style.Animations><Animation Duration="0:0:1" PlaybackDirection="Alternate" IterationCount="2"><KeyFrame Cue="0%"><Setter Property="FontSize" Value="14"/></KeyFrame><KeyFrame Cue="100%"><Setter Property="FontSize" Value="20"/></KeyFrame></Animation></Style.Animations></Style><!--选中状态--><Style Selector="^:selected"><Setter Property="Background" Value="{StaticResource SelectedBackgroundBrush}"/><Setter Property="Foreground" Value="{StaticResource SelectedForegroundBrush}"/></Style>    </Style><!-- 垂直 ScrollBar 模板 --><Style Selector="ListBox /template/ ScrollViewer /template/ ScrollBar:vertical"><Setter Property="Width" Value="15"/><Setter Property="Template"><ControlTemplate><Grid RowDefinitions="18,*,18"><RepeatButton Grid.Row="0" Name="PART_LineUpButton" Background="{StaticResource StandardBackgroundBrush}"><Path Fill="{StaticResource GlyphBrush}"Data="M 0 4 L 8 4 L 4 0 Z"Width="8" Height="4" /></RepeatButton><Track Grid.Row="1"Name="PART_Track"Minimum="{TemplateBinding Minimum}"Maximum="{TemplateBinding Maximum}"        Value="{TemplateBinding Value, Mode=TwoWay}"    ViewportSize="{TemplateBinding ViewportSize}"Orientation="{TemplateBinding Orientation}"IsDirectionReversed="True"><Track.Thumb><Thumb Name="PART_Thumb"/></Track.Thumb></Track><RepeatButton Grid.Row="2" Name="PART_LineDownButton" Background="{StaticResource StandardBackgroundBrush}"><Path Fill="{StaticResource GlyphBrush}"Data="M 0 0 L 4 4 L 8 0 Z"Width="8" Height="4" /></RepeatButton></Grid></ControlTemplate></Setter></Style><!-- 滚动条 Thumb --><Style Selector="ListBox /template/ ScrollViewer /template/ ScrollBar /template/ Thumb"><Setter Property="Background" Value="{StaticResource StandardBackgroundBrush}" /><Setter Property="BorderBrush" Value="{StaticResource StandardBorderBrush}" /><Setter Property="BorderThickness" Value="1" /><Setter Property="CornerRadius" Value="12" /><Setter Property="Template"><ControlTemplate><Border Background="{TemplateBinding Background}"BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"CornerRadius="{TemplateBinding CornerRadius}" /></ControlTemplate></Setter><!-- 鼠标悬停状态 --><Style Selector="^:pointerover"><Setter Property="Background" Value="{StaticResource HoverBorderBrush}" /><Setter Property="BorderBrush" Value="{StaticResource HoverBorderBrush}" /></Style><!-- 鼠标离开状态 --><Style Selector="^:not(:pointerover)"><Setter Property="Background" Value="{StaticResource StandardBackgroundBrush}" /><Setter Property="BorderBrush" Value="{StaticResource StandardBorderBrush}" /></Style></Style></Window.Styles><Grid Margin="10"><ListBox><ListBoxItem>🍎 Apple</ListBoxItem><ListBoxItem>🍌 Banana</ListBoxItem><ListBoxItem>🍇 Grape</ListBoxItem><ListBoxItem>🍊 Orange</ListBoxItem><ListBoxItem>🍉 Watermelon</ListBoxItem><ListBoxItem>🍓 Strawberry</ListBoxItem><ListBoxItem>🍍 Pineapple</ListBoxItem><ListBoxItem>🥝 Kiwi</ListBoxItem><ListBoxItem>🍒 Cherry</ListBoxItem><ListBoxItem>🍑 Peach</ListBoxItem></ListBox></Grid>
</Window>

MultiPartTemplates.axaml.cs代码

using Avalonia;
using Avalonia.Controls;namespace AvaloniaUI;public partial class MultiPartTemplates : Window
{public MultiPartTemplates(){InitializeComponent();}
}

运行效果

image

 

http://www.fuzeviewer.com/news/9008/

相关文章:

  • 口碑好网站建设费用网站建设的关键事项
  • 知道网站域名怎么联系产品设计就业方向
  • 电子商务网站建设品牌别人品牌的域名做网站吗
  • 网站上传不了图片不显示不出来广东省建设工程质量安全监督检测总站网站
  • 网站关键词更换了福田公司在哪里
  • 网站模板但没有后台如何做网站京津冀协同发展规划纲要全文 pdf
  • 基于asp的医疗网站开发义乌网络
  • 外贸营销网站建设方案正规的南昌网站建设
  • 苏州网站与网站云相关的词语
  • 网站建设课后感电子商务应用平台包括哪些
  • 企业网站建设模块广东seo快速排名
  • 网站建设亿玛酷信赖优速网站建设工作室
  • 蓝色科技企业网站模板免费下载vs做网站标签输出语言
  • 做汽车网站开题报告的意义如何创建wordpress数据库
  • 凡科建站登录入口ae模板免费下载网站有哪些
  • 建个企业网站需要什么商旅网站建设
  • 怎么在工商局网站做股东变更wordpress 模板 门户
  • 做网站用啥语言建筑招工找活平台
  • 高端网站建设企业官网建设家里做网站买什么服务器好
  • 企业网站建设费用计入哪个科目网站模板怎么修改教程
  • 做网站还有开发文档吗平台网址怎么查询
  • 江阴网站建设工作室邯郸市出租房屋信息网
  • 网站维护流程前端页面设计网站
  • 网站开发 经常要清理缓存网站开发设计费 怎么入账
  • 网站怎么做页面解析跳转现代简约装修
  • 网站优化推广公司做包装盒有哪些网站
  • wordpress这软件怎么搜索seo网站优化培训价格
  • 权威发布e站网站建设手机银行修改登录密码
  • 专门做男装的网站哪些网站做魔兽地图
  • h5网站建设+北京个人网站的设计流程