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 如果显示版本号表示安 ...
随机推荐
- TFS--解决新创建的windows用户无法访问TFS的问题
今天入职新同事,帮忙配置TFS的账号碰到一个问题,TFS账号是映射取administrators组得 所以新建用户之后,无法马上引入TFS.查询原因是 Builtin组中没有该账号,以前也总是碰到新加 ...
- XAMPP中Apache因为端口原因不能启动的解决方法
在开启XAMPP的Apache时报出如下错误信息: 9:08:14 PM [Apache] Error: Apache shutdown unexpectedly.9:08:14 PM [Apache ...
- 「C语言」数据类型及混合运算与类型转换
深入学习C语言时,有必要先了解一下数据类型的概念,以及它们之间的混合运算与类型转换. 本篇文章便是根据<C语言程序设计教程>和在线翻阅资料后整理而出.(练习题将逐步更新) 目录: ...
- ListView实现分页加载(二)实现底布局
上一篇中,我们搭建好了一个Demo.没有阅读的可以点击下面的链接: http://www.cnblogs.com/fuly550871915/p/4866929.html 在这一篇中,我们将实现Lis ...
- JDK工具系列之jps
一.简介 jps(JVM Process Status Tool)是虚拟机进程状态工具:可以列出正在运行的虚拟机进程,显示虚拟机正在执行的main()函数,及这些进程的ID(LVMID,Local V ...
- ASP.NET Web API编程——接口安全与角色控制
1 API接口验证与授权 JWT JWT定义,它包含三部分:header,payload,signature:每一部分都是使用Base64编码的JSON字符串.之间以句号分隔.signature是”h ...
- C# 实现Excel读取接口写入数据
[Route("adm/getInfo")] [HttpGet] public string GetInfo() { var types = typeof(GCP.Server.W ...
- 十七、IntelliJ IDEA 中的 Maven 项目初体验及搭建 Spring MVC 框架
我们已经将 IntelliJ IDEA 中的 Maven 项目的框架搭建完成.接着上文,在本文中,我们更近一步,利用 Tomcat 运行我们的 Web 项目. 如上图所示,我们进一步扩展了项目的结构, ...
- 十三、IntelliJ IDEA 中的版本控制介绍(下)
我们已经简单了解了 IntelliJ IDEA 的版本控制机制,那么接下来,就让我们一起看看在 IntelliJ IDEA 中进行具体的版本控制操作. 标注1:Checkout from Versio ...
- IOS9中使用NSURLConection发送异步网络请求
IOS9中使用NSURLConection发送异步网络请求 在ios9中,NSURLConection的sendSync..和sendAsync已经过时.被NSURLSession代替. 以下蓝色部分 ...