Prism for WPF 搭建一个简单的模块化开发框架(二)
原文:Prism for WPF 搭建一个简单的模块化开发框架(二)
今天又有时间了,再改改,加了一些控件全局的样式
样式代码
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--TextBlock-->
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource Sys.Foreground}"/>
<Setter Property="FontFamily" Value="{DynamicResource Sys.FontFamily}"/>
<Setter Property="FontSize" Value="{DynamicResource Sys.FontSize}"/>
<Setter Property="Padding" Value="0,3,0,0"/>
</Style>
<!--下拉框-->
<Style TargetType="ComboBox">
<Setter Property="Foreground" Value="Black"/>
</Style>
<Style TargetType="ComboBoxItem">
<Setter Property="Foreground" Value="Black"/>
</Style>
<!--文本框-->
<Style TargetType="TextBox">
<Setter Property="Foreground" Value="{DynamicResource Sys.Input.Foreground}"/>
<Setter Property="Background" Value="{DynamicResource Sys.Input.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Sys.Input.BorderBrush}"/>
<Setter Property="FontSize" Value="{DynamicResource Sys.Input.FontSize}"/>
<Setter Property="BorderThickness" Value="{DynamicResource Sys.Input.BorderThickness}"/>
<Setter Property="Height" Value="20"/>
</Style>
<Style TargetType="PasswordBox">
<Setter Property="Foreground" Value="{DynamicResource Sys.Input.Foreground}"/>
<Setter Property="Background" Value="{DynamicResource Sys.Input.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Sys.Input.BorderBrush}"/>
<Setter Property="FontSize" Value="{DynamicResource Sys.Input.FontSize}"/>
<Setter Property="BorderThickness" Value="{DynamicResource Sys.Input.BorderThickness}"/>
<Setter Property="Height" Value="20"/>
</Style>
<!--复选框-->
<Style TargetType="CheckBox">
<Setter Property="Foreground" Value="{DynamicResource Sys.Input.Foreground}"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="4,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Duration="0" To="{DynamicResource Sys.Input.MouseOver.BorderBrush}" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="hotbg_20" />
</Storyboard>
</VisualState>
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled"/>
<VisualState x:Name="Pressed"/>
</VisualStateGroup>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="CheckIcon">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ColorAnimation Duration="0" To="{DynamicResource Sys.Input.Checked.BorderBrush}" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="hotbg_20" />
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked"/>
<VisualState x:Name="Indeterminate">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="IndeterminateIcon">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Viewbox HorizontalAlignment="Center" VerticalAlignment="Center" Height="23">
<Grid>
<Path x:Name="hotbg_20" Stretch="Fill" StrokeThickness="1.33333" StrokeLineJoin="Round" Fill="{DynamicResource Sys.Input.Background}" Stroke="{DynamicResource Sys.Input.BorderBrush}" Data="F1 M 746.405,724.995L 725.944,724.995C 725.703,724.995 725.508,724.534 725.508,723.966L 725.508,704.689C 725.508,704.122 725.703,703.661 725.944,703.661L 746.405,703.661C 746.646,703.661 746.841,704.122 746.841,704.689L 746.841,723.966C 746.841,724.534 746.646,724.995 746.405,724.995 Z " UseLayoutRounding="False">
<!--<Path.Fill>
<RadialGradientBrush RadiusX="1.96789" RadiusY="1.89722" Center="0.0848637,0.291189" GradientOrigin="0.0848637,0.291189">
<RadialGradientBrush.RelativeTransform>
<TransformGroup>
<SkewTransform CenterX="0.0848637" CenterY="0.291189" AngleX="-13.2747" AngleY="0"/>
<RotateTransform CenterX="0.0848637" CenterY="0.291189" Angle="37.211"/>
</TransformGroup>
</RadialGradientBrush.RelativeTransform>
<GradientStop Color="#303EAFFF" Offset="0.0858586"/>
<GradientStop Color="#302463FF" Offset="0.301316"/>
<GradientStop Color="#300A17FF" Offset="0.555556"/>
<GradientStop Color="#302474FF" Offset="0.828512"/>
<GradientStop Color="#303ED1FF" Offset="0.969697"/>
</RadialGradientBrush>
</Path.Fill>-->
</Path>
<Path x:Name="CheckIcon" Data="M102.03442,598.79645 L105.22962,597.78918 L106.78825,600.42358 C106.78825,600.42358 108.51028,595.74304 110.21724,593.60419 C112.00967,591.35822 114.89314,591.42316 114.89314,591.42316 C114.89314,591.42316 112.67844,593.42645 111.93174,594.44464 C110.7449,596.06293 107.15683,604.13837 107.15683,604.13837 z" Fill="{DynamicResource Sys.Input.Foreground}" FlowDirection="LeftToRight" Stretch="Fill" HorizontalAlignment="Center" UseLayoutRounding="False" VerticalAlignment="Center" Visibility="Collapsed"/>
<Border x:Name="IndeterminateIcon" Background="{DynamicResource Sys.Input.Foreground}" Margin="4,9" Visibility="Collapsed"/>
</Grid>
</Viewbox>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Column="1" Margin="{TemplateBinding Padding}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--单选框-->
<Style TargetType="RadioButton">
<Setter Property="Foreground" Value="{DynamicResource Sys.Input.Foreground}"/>
</Style>
<!--Button-->
<Style TargetType="Button">
<Setter Property="FontSize" Value="{DynamicResource Sys.FontSize}"/>
<Setter Property="Foreground" Value="{DynamicResource Sys.Foreground}"/>
<Setter Property="FontFamily" Value="{DynamicResource Sys.FontFamily}"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Background" Value="{DynamicResource Sys.Button.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Sys.Button.BorderBrush}"/>
<Setter Property="BorderThickness" Value="{DynamicResource Sys.Button.BorderThickness}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border" CornerRadius="1" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
<ContentPresenter Name="content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource Sys.Button.MouseOver.Background}">
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource Sys.Button.Pressed.Background}">
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="border" Property="Opacity" Value="0.6" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
然后又做了个配置系统的名称等信息的xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:PW="clr-namespace:PW.Desktop">
<sys:String x:Key="System.Title">这里是系统名称</sys:String>
<sys:String x:Key="System.TitleEN">this is system name</sys:String>
<sys:String x:Key="System.Company">xxxxx有限公司</sys:String>
<sys:String x:Key="System.Version">1.0.0</sys:String>
<sys:String x:Key="System.Copyright">Copyright © 2018 xxxxx有限公司</sys:String>
</ResourceDictionary>
做了个两个字体的文本样式,一个是用来做图标的,一个是液晶字体,用在特殊情况下显示数字
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--FIcon-->
<Style x:Key="FIcon" TargetType="TextBlock">
<Setter Property="FontFamily" Value="pack://application:,,,/PW.Desktop;component/Resources/#SF2015"></Setter>
<!--<Setter Property="FontFamily" Value="../Resources/iconfont.ttf#SF2015"></Setter>-->
<Setter Property="Foreground" Value="{StaticResource ModuleControl.TextBlock.Foreground}"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="{StaticResource Sys.IconFontSize}"/>
<Setter Property="Width" Value="20"/>
<Setter Property="Height" Value="20"/>
<Setter Property="Margin" Value="4,2,4,2"/>
</Style>
<Style x:Key="QuartzRegular">
<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/PW.Desktop;component/Resources/#Quartz Regular" />
</Style>
</ResourceDictionary>
字体文件我就不贴了,网上都有
用法是这样的
<TextBlock x:Name="navIco" Text="" Style="{DynamicResource FIcon}"></TextBlock>
这里注意这里的写法是
然后如果是用后台代码给赋值就要写成这样的
具体是在哪里给转义了还不清楚
最后把这些文件都引入到主工程的App.xaml下面
两种引用方法都行,ModularityStyles.xaml是系统的一些配色
看一下效果
这里不同的模块内设置按钮的背景色和名称,然后在登陆模块去加载并显示到页面,包括下面的导航按钮图标
这里右上角的导航条的文本和图标就是在各模块设置的,这样写
public void Initialize()
{
GlobalData.NavModules.Add(new NavModuleInfo() { region = RegionNames.Main, module = ModuleNames.Map, title = ModuleTitle.Map, icon = "\xe63c", img= Images.CreateImageSourceFromImage(Properties.Resources.avtar) });
this.moduleTracker.RecordModuleInitialized(ModuleNames.Map);
regionManager.RegisterViewWithRegion(RegionNames.Main, typeof(MapModule_MainView));
}
就两个模块然后就两个按钮看起来好像有些小气,,,,
下次准备把左侧的导航做出来
Prism for WPF 搭建一个简单的模块化开发框架(二)的更多相关文章
- Prism for WPF 搭建一个简单的模块化开发框架 (一个节点)
原文:Prism for WPF 搭建一个简单的模块化开发框架 (一个节点) 这里我就只贴图不贴代码了,看看这个节点之前的效果 觉得做的好的地方可以范之前的文章看看 有好的建议也可以说说 填充数据 ...
- Prism for WPF 搭建一个简单的模块化开发框架(六)隐藏菜单、导航
原文:Prism for WPF 搭建一个简单的模块化开发框架(六)隐藏菜单.导航 这个实际上是在聊天之前做的,一起写了,也不分先后了 看一下效果图,上面是模块主导航,左侧是模块内菜单,现在加一下隐藏 ...
- Prism for WPF 搭建一个简单的模块化开发框架(四)异步调用WCF服务、WCF消息头添加安全验证Token
原文:Prism for WPF 搭建一个简单的模块化开发框架(四)异步调用WCF服务.WCF消息头添加安全验证Token 为什么选择wcf? 因为好像wcf和wpf就是哥俩,,, 为什么选择异步 ...
- Prism for WPF 搭建一个简单的模块化开发框架(五)添加聊天、消息模块
原文:Prism for WPF 搭建一个简单的模块化开发框架(五)添加聊天.消息模块 中秋节假期没事继续搞了搞 做了各聊天的模块,需要继续优化 第一步画页面 页面参考https://github.c ...
- Prism for WPF 搭建一个简单的模块化开发框架(三) 给TreeView加样式做成菜单
原文:Prism for WPF 搭建一个简单的模块化开发框架(三) 给TreeView加样式做成菜单 昨天晚上把TreeView的样式做了一下,今天给TreeView绑了数据,实现了切换页面功能 上 ...
- Prism for WPF 搭建一个简单的模块化开发框架(一)
原文:Prism for WPF 搭建一个简单的模块化开发框架(一) 最近闲来无事又想搞搞WPF..... 做个框架吧,可能又是半途而废....总是坚持不下来 不废话了, 先看一下工程结构 布局大概是 ...
- 用express搭建一个简单的博客系统
转自:https://blog.csdn.net/qq_29721837/article/details/62055603 Express 简介 Express 是一个简洁而灵活的 node.js W ...
- 从零开始搭建一个简单的基于webpack的vue开发环境
原文地址:https://segmentfault.com/a/1190000012789253?utm_source=tag-newest 从零开始搭建一个简单的基于webpack的react开发环 ...
- 用nodejs搭建一个简单的服务器
使用nodejs搭建一个简单的服务器 nodejs优点:性能高(读写文件) 数据操作能力强 官网:www.nodejs.org 验证是否安装成功:cmd命令行中输入node -v 如果显示版本号表示安 ...
随机推荐
- jQuery插件开发精品教程,让你的jQuery提升一个台阶(转)
原文:http://www.cnblogs.com/Wayou/p/jquery_plugin_tutorial.html 要说jQuery 最成功的地方,我认为是它的可扩展性吸引了众多开发者为其开发 ...
- SAP S/4HANA使用ABAP获得生产订单的状态
在S/4HANA里,我们如何根据一个销售订单的行项目,查看对应的生产订单状态? 双击行项目: 点击Schedule line: 这里就能看到生产订单的ID和状态了. 其中订单的状态存储在表vsaufk ...
- BZOJ2654:tree(最小生成树,二分)
Description 给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有need条白色边的生成树. 题目保证有解. Input 第一行V,E,need分别表示点数,边数和需要的白色 ...
- HDU 6386 Age of Moyu 【BFS + 优先队列优化】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6386 Age of Moyu Time Limit: 5000/2500 MS (Java/Others ...
- springboot——我的第一个工程
前言:使用Spring Boot 微服务架构有一段时间了,打算从今天开始记录使用过程. 一.Spring Boot介绍: 简介:Spring Boot 框架的产生,是为了方便我们简化Spring 框架 ...
- 树莓派图形界面启动chromium并全屏
方法1. 随便一搜都是这种方法 创建文件: /home/pi/.config/autostart/my.desktop 文件名随意, 后缀必须.desktop 文件内容: [Desktop ...
- Objective-C中,ARC下的 strong和weak指针原理解释
Objective-C中,ARC下的 strong和weak指针原理解释 提示:本文中所说的"实例变量"即是"成员变量","局部变量"即是& ...
- Java日期类题目
每类题都有各种各样解决的方式,大家随意发散 分析以下需求,并用代码实现 1.已知日期字符串:"2015-10-20",将该日期字符串转换为日期对象 2.将(1)中的日期对象转换为日 ...
- Reading Notes : 180214 计算机的总线结构
读书<计算机组成原理>,百度百科 基本上接触过计算机的人,都多少知道计算机的具体构成,但是真正能讲明白的却说了很多,本节将讲解一下计算机的基本硬件构成和一些基本信息,简单认识,以后再深入了 ...
- Oracle GoldenGate同步服务归档空间维护
ORA-00257: archiver error. Connect internal only, until freed 查看归档日志序列 SQL> archive log list; Aut ...