Textbox error template<Style x:Key="ControlBaseStyle" TargetType="{x:Type Control}">
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Control.IsEnabled" Value="False"/>
<Condition Property="Control.IsHitTestVisible" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Control.Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
</MultiTrigger>
</Style.Triggers>
</Style> <Style x:Key="TextBoxErrorToolTipStyle" TargetType="{x:Type Control}" BasedOn="{StaticResource ControlBaseStyle}">
<Style.Setters>
<Setter Property="Control.ContextMenu" Value="{StaticResource TextBoxContextMenu}" />
<Setter Property="Control.HorizontalAlignment" Value="Stretch"/>
<Setter Property="Control.VerticalAlignment" Value="Center"/>
<Setter Property="Control.Margin" Value="3,3"/> </Style.Setters>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Validation.HasError" Value="True" />
<Condition Property="IsEnabled" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
<Setter Property="Validation.ErrorTemplate"
Value="{DynamicResource ValidationErrorTemplate}"/>
</MultiTrigger>
</Style.Triggers> </Style>
<ControlTemplate x:Key="ValidationErrorTemplate">
<DockPanel LastChildFill="True">
<Border BorderBrush="Red" BorderThickness="1">
<AdornedElementPlaceholder Name="rangeErrorAdorner" Margin="-1,-1" />
</Border>
</DockPanel>
</ControlTemplate>
自定义Expander<UserControl x:Class="GenericProfile.CustomerExpander"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="150" d:DesignWidth="450">
<UserControl.Resources>
<ResourceDictionary>
</ResourceDictionary>
</UserControl.Resources>
<Expander
HorizontalAlignment="Left"
VerticalAlignment="Top"
IsExpanded="False"
Height="Auto"
Width="450" BorderBrush="Black" BorderThickness="2"> <Expander.Header>
<Grid Height="Auto" Width="398">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="35"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition /> </Grid.ColumnDefinitions>
<TextBlock Text="Language:" Grid.Column="1" VerticalAlignment="Center"/>
<TextBlock Text="English" Grid.Column="3" Visibility="Collapsed"/>
<ComboBox Grid.Column="3" x:Name="languagesCombox" MinWidth="120" HorizontalAlignment="Left" VerticalAlignment="Bottom" SelectionChanged="languageCombox_SelectionChanged" />
<TextBlock Text="×" x:Name="deleteTextBlock" FontSize="20" Foreground="Red" Grid.Column="7" HorizontalAlignment="Right" FontWeight="Black" TextAlignment="Center" MouseLeftButtonDown="deleteTextBlock_MouseLeftButtonDown" />
</Grid>
</Expander.Header>
<Expander.Content>
<Grid Height="116">
<Grid.RowDefinitions>
<RowDefinition Height="15"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="15"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="15" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<TextBlock Text="Description:" Grid.Column="1" Grid.Row="1"/>
<TextBox x:Name="descriptionTextBox" Grid.Column="3" Grid.Row="1" MinWidth="300px" MinHeight="50px" />
<TextBlock Text="Help File:" Grid.Column="1" Grid.Row="3"/>
<TextBox x:Name="helpFilePath" Grid.Column="3" Grid.Row="3" Width="250" HorizontalAlignment="Left" Text="{Binding Path=HelpFilePath,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}"/>
<Button Grid.Column="3" Grid.Row="3" x:Name="selectFileBtn" Content="..." Width="24" Height="Auto" HorizontalAlignment="Right" Click="selectFileBtn_Click" />
</Grid>
</Expander.Content>
</Expander>
</UserControl>
虚线边框<UserControl x:Class="CustomControls.CustomAddLanguage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignWidth="450" Height="30">
<UserControl.Resources>
<ResourceDictionary>
<Style x:Key="CustomBoarder"> </Style>
</ResourceDictionary>
</UserControl.Resources>
<Border>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="15" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Rectangle Stroke="Gray" Height="30" StrokeThickness="2" StrokeDashArray="4 4" Grid.ColumnSpan="4"
SnapsToDevicePixels="True" RadiusX="10" RadiusY="10"/>
<TextBlock Text="+" Grid.Column="1" Foreground="Gray" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,8" />
<TextBlock Text="Add other language" Foreground="Gray" FontSize="16" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" />
</Grid>
</Border> </UserControl>
 
自定义DataGrid Column的格式    <!--DataTemplate for Published Date column defined in Grid.Resources.  PublishDate is a property on the ItemsSource of type DateTime -->
<DataTemplate x:Key="DateTemplate" >
<StackPanel Width="20" Height="30">
<Border Background="LightBlue" BorderBrush="Black" BorderThickness="1">
<TextBlock Text="{Binding PublishDate, StringFormat={}{0:MMM}}" FontSize="8" HorizontalAlignment="Center" />
</Border>
<Border Background="White" BorderBrush="Black" BorderThickness="1">
<TextBlock Text="{Binding PublishDate, StringFormat={}{0:yyyy}}" FontSize="8" FontWeight="Bold" HorizontalAlignment="Center" />
</Border>
</StackPanel>
</DataTemplate>
<!--DataTemplate for the Published Date column when in edit mode. -->
<DataTemplate x:Key="EditingDateTemplate">
<DatePicker SelectedDate="{Binding PublishDate}" />
</DataTemplate>
<DataGrid Name="DG1" ItemsSource="{Binding}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<!--Custom column that shows the published date-->
<DataGridTemplateColumn Header="Publish Date" CellTemplate="{StaticResource DateTemplate}" CellEditingTemplate="{StaticResource EditingDateTemplate}" />
</DataGrid.Columns>
</DataGrid>

WPF常用资源的更多相关文章

  1. WPF常用控件应用demo

    WPF常用控件应用demo 一.Demo 1.Demo截图如下: 2.demo实现过程 总体布局:因放大缩小窗体,控件很根据空间是否足够改变布局,故用WrapPanel布局. <ScrollVi ...

  2. 【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇一:WPF常用知识以及本项目设计总结

    篇一:WPF常用知识以及本项目设计总结:http://www.cnblogs.com/baiboy/p/wpf.html 篇二:基于OneNote难点突破和批量识别:http://www.cnblog ...

  3. 基于java平台的常用资源整理

    这里整理了基于java平台的常用资源 翻译 from :akullpp | awesome-java 大家一起学习,共同进步. 如果大家觉得有用,就mark一下,赞一下,或评论一下,让更多的人知道.t ...

  4. 这里整理了基于java平台的常用资源

    这里整理了基于java平台的常用资源 翻译 from :akullpp | awesome-java 大家一起学习,共同进步. 如果大家觉得有用,就mark一下,赞一下,或评论一下,让更多的人知道.t ...

  5. WPF之资源字典zz

    最近在看wpf相关东西,虽然有过两年的wpf方面的开发经验,但是当时开发的时候,许多东西一知半解,至今都是模模糊糊,框架基本是别人搭建,自己也就照着模板写写,现在许多东西慢慢的理解了,回顾以前的若干记 ...

  6. WPF 之 资源(Resource)

    1.什么叫WPF的资源(Resource)? 资源是保存在可执行文件中的一种不可执行数据.在WPF的资源中,几乎可以包含图像.字符串等所有的任意CLR对象,只要对象有一个默认的构造函数和独立的属性. ...

  7. WPF 中资源路径的问题

    WPF 中资源路径的问题 1. 引用当前工程的资源(注意xxxx.png的build action 应设置为Resource 或Embedded Resource) <ImageBrush Im ...

  8. WPF样式资源文件简单运用

    WPF通过资源来保存一些可以被重复利用的样式,下面的示例展示了简单的资源样式文件的使用: 一.xaml中定义资源及简单的引用 <Window.Resources > <!--wpf窗 ...

  9. WPF常用转换

    原文 WPF常用转换 以下是代码中常常用到的一些转换,整理如下,后续再不断完善: 1.string和Color的转换 //string转Color (Color)ColorConverter.Conv ...

随机推荐

  1. CSS 三栏布局入门

    首先,我是CSS盲[只听说过box model],没动手实践过,关于margin padding只知名称,不明细节.刚看过一叶斋大哥关于css布局的博文,再动手实践,动手记录下点滴积累以备后用. &l ...

  2. MacType 缺字问题【转】

  3. Spring boot application.properties 配置

    原文链接: http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.ht ...

  4. Win7系统下调整硬盘分区大小给C盘更多的空间

    电脑安装了很多程序,C盘空间越来越小了.如何给C盘调整更多的空间,其实只要调整硬盘分区大小便可解决这个问题,下面有个小技巧,需要的朋友照做就可以了 Win7系统下如何调整硬盘分区大小,以前装系统的时候 ...

  5. SQL数据查询2

    USE h CREATE TABLE zy1( empno INT, ename ), job ), mgr INT, hiredate DATE, sal DOUBLE, COOM DOUBLE, ...

  6. hibernate简单集合映射和获取

    简单集合映射(可以直接获取) // javabean设计 public class User { private int userId; private String userName; // 一个用 ...

  7. 洛谷 P1137 旅行计划 (拓扑排序+dp)

    在DAG中,拓扑排序可以确定dp的顺序 把图的信息转化到一个拓扑序上 注意转移的时候要用边转移 这道题的dp是用刷表法 #include<bits/stdc++.h> #define RE ...

  8. react 简单在页面中输出一段文字

    之前用脚手架创建了一个react项目,将react自带的src文件夹删除后创建一个空的src文件夹 在src文件夹中创建一个index.jsx文件作为JS入口文件并创建一个hello组件 现在我们进入 ...

  9. 《代码敲不队》第八次团队作业:Alpha冲刺 第二天

    项目 内容 这个作业属于哪个课程 任课教师博客主页链接 这个作业的要求在哪里 作业链接地址 团队名称 代码敲不队 作业学习目标 掌握软件编码实现的工程要求. 团队项目github仓库地址链接 GitH ...

  10. Jenkins学习总结(6)——了解DevOps的前世今生

    DevOps是什么?从哪里来? DevOps的概念 DevOps一词的来自于Development和Operations的组合,突出重视软件开发人员和运维人员的沟通合作,通过自动化流程来使得软件构建. ...