找回密码
 立即注册

QQ登录

只需一步,快速开始

CanYou1

高级会员

45

主题

227

帖子

1359

积分

高级会员

积分
1359

活字格认证微信认证勋章元老葡萄

CanYou1
高级会员   /  发表于:2015-5-5 14:24  /   查看:7306  /  回复:8
如下面几个图内的文字说明:




期望的效果:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

8 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2015-5-5 17:11:00
沙发
回复 1楼CanYou1的帖子

感谢你对该问题的反馈。
根据你的图片,我还有一些地方和你确认。
我理解你的需求是,界面上放置C1MaskedText控件,然后使用了校验?
你的需求就是期望焦点离开的时候,提示内容不消失?
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
CanYou1
高级会员   /  发表于:2015-5-5 18:26:00
板凳
对啊,就是这样,可以吗?
回复 使用道具 举报
CanYou1
高级会员   /  发表于:2015-5-5 18:27:00
地板
回复 2楼Alice的帖子

对啊,就是这样
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2015-5-6 09:02:00
5#
回复 3楼CanYou1的帖子

感谢你的反馈。
从接口本身来看,没有这类接口。
但基于WPF平台的控件在自定义方面有很大的灵活性,基于这点,我需要校验下,然后才能给你反馈是否可行。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
CanYou1
高级会员   /  发表于:2015-5-6 09:46:00
6#
回复 5楼Alice的帖子

好的,非常感谢!如果能做到就最好了,现在我们的客户总说看不到提示信息,其实都是因为离焦了导致的
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2015-5-6 15:08:00
7#
回复 6楼CanYou1的帖子

你好。
这个问题和之前你提到的C1MaskedTextBox的改变Tooltip背景色的问题有类似的方法,都是不能直接设置的,需要重写模板。
基本思路就是,设置C1MaskedTextBox的ValidationDecoratorStyle="{StaticResource C1ValidationDecoratorStyle1}", 然后重写模板。
重写模板的这部分代码已经实现了,如下所示。
该代码在离开焦点的时候,依然会校验。
以下代码只是针对这个需求,如果在你添加到你的产品中,由于会存在业务逻辑,这部分还需要你们专业的测试验证正确性。
  1.    <Style x:Key="ValidationToolTipStyle" TargetType="{x:Type ToolTip}">
  2.                 <Setter Property="Background" Value="Red" />
  3.                 <Setter Property="Foreground" Value="Green" />
  4.                 <Setter Property="Template">
  5.                     <Setter.Value>
  6.                         <ControlTemplate TargetType="{x:Type ToolTip}">

  7.                             <Grid x:Name="Root" Margin="5 0">
  8.                                 <Border Background="{TemplateBinding Background}" CornerRadius="2">
  9.                                     <ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
  10.                                 </Border>
  11.                             </Grid>

  12.                         </ControlTemplate>
  13.                     </Setter.Value>
  14.                 </Setter>
  15.             </Style>

  16.             <!-- C1ValidationDecorator Style-->
  17.             <Style x:Key="C1ValidationDecoratorStyle1" TargetType="{x:Type c1:C1ValidationDecorator}">
  18.                 <Setter Property="Background" Value="Red" />
  19.                 <Setter Property="Foreground" Value="Green" />
  20.                 <Setter Property="CornerRadius" Value="1" />
  21.                 <Setter Property="BorderThickness" Value="1" />
  22.                 <Setter Property="IsTabStop" Value="False" />
  23.                 <Setter Property="IsHitTestVisible" Value="False" />
  24.                 <Setter Property="Template">
  25.                     <Setter.Value>
  26.                         <ControlTemplate TargetType="{x:Type c1:C1ValidationDecorator}">
  27.                             <Border x:Name="ValidationErrorElement" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding Background}" Visibility="Collapsed">
  28.                                 <VisualStateManager.VisualStateGroups>
  29.                                     <VisualStateGroup x:Name="ValidationStates">
  30.                                         <VisualState x:Name="Valid" />
  31.                                         <VisualState x:Name="InvalidUnfocused">
  32.                                             <Storyboard>
  33.                                                 <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
  34.                                                     <DiscreteObjectKeyFrame KeyTime="0">
  35.                                                         <DiscreteObjectKeyFrame.Value>
  36.                                                             <Visibility>Visible</Visibility>
  37.                                                         </DiscreteObjectKeyFrame.Value>
  38.                                                     </DiscreteObjectKeyFrame>
  39.                                                 </ObjectAnimationUsingKeyFrames>
  40.                                                 <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen">
  41.                                                     <DiscreteObjectKeyFrame KeyTime="0">
  42.                                                         <DiscreteObjectKeyFrame.Value>
  43.                                                             <System:Boolean>True</System:Boolean>
  44.                                                         </DiscreteObjectKeyFrame.Value>
  45.                                                     </DiscreteObjectKeyFrame>
  46.                                                 </ObjectAnimationUsingKeyFrames>
  47.                                             </Storyboard>
  48.                                         </VisualState>
  49.                                         <VisualState x:Name="InvalidFocused">
  50.                                             <Storyboard>
  51.                                                 <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
  52.                                                     <DiscreteObjectKeyFrame KeyTime="0">
  53.                                                         <DiscreteObjectKeyFrame.Value>
  54.                                                             <Visibility>Visible</Visibility>
  55.                                                         </DiscreteObjectKeyFrame.Value>
  56.                                                     </DiscreteObjectKeyFrame>
  57.                                                 </ObjectAnimationUsingKeyFrames>
  58.                                                 <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen">
  59.                                                     <DiscreteObjectKeyFrame KeyTime="0">
  60.                                                         <DiscreteObjectKeyFrame.Value>
  61.                                                             <System:Boolean>True</System:Boolean>
  62.                                                         </DiscreteObjectKeyFrame.Value>
  63.                                                     </DiscreteObjectKeyFrame>
  64.                                                 </ObjectAnimationUsingKeyFrames>
  65.                                             </Storyboard>
  66.                                         </VisualState>
  67.                                     </VisualStateGroup>
  68.                                 </VisualStateManager.VisualStateGroups>
  69.                                 <ToolTipService.ToolTip>
  70.                                     <ToolTip x:Name="validationTooltip" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Placement="Right" PlacementTarget="{TemplateBinding Target}" Style="{StaticResource ValidationToolTipStyle}" Content="{Binding Target.(Validation.Errors), RelativeSource={RelativeSource TemplatedParent}}">
  71.                                         <ToolTip.ContentTemplate>
  72.                                             <DataTemplate>
  73.                                                 <TextBlock Margin="8 4" MaxWidth="250" VerticalAlignment="Center" Text="{Binding [0].ErrorContent}" TextWrapping="Wrap" />
  74.                                             </DataTemplate>
  75.                                         </ToolTip.ContentTemplate>

  76.                                     </ToolTip>
  77.                                 </ToolTipService.ToolTip>
  78.                                 <Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="{TemplateBinding Background}" Margin="0 -1 -1 0" HorizontalAlignment="Right" VerticalAlignment="Top" />
  79.                             </Border>
  80.                         </ControlTemplate>
  81.                     </Setter.Value>
  82.                 </Setter>
  83.             </Style>
复制代码
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
CanYou1
高级会员   /  发表于:2015-5-6 16:19:00
8#
回复 7楼Alice的帖子

好的,谢谢。我找个时间再验证下。
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2015-5-6 16:54:00
9#
回复 8楼CanYou1的帖子

好的。
我会跟进你的问题。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部