TextBox的控件模板的ColorAmination问题 [英] ColorAmination problem with TextBox's control template

查看:56
本文介绍了TextBox的控件模板的ColorAmination问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!
我用一些TextBoxs创建了一个WPF项目.我使用以下xaml代码应用了控制模板:

Hello!
I created a WPF project with some TextBoxs. I applied control template using the following xaml code:

<Style TargetType="TextBox">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="Template">
        <Setter.Value> 
          <ControlTemplate TargetType="TextBox">
            <Grid> 
               <Ellipse Fill="Navy"/>
               <ContentPresenter HorizontalAlignment="Center"

                                 VerticalAlignment="Center"/> 
            </Grid>
          </ControlTemplate> 
        </Setter.Value>
     </Setter> 
</Style> 



我使用ColorAmination来使用c#代码胺化TextBoxs的背景色.

ControlTemplate正常工作,但ColorAmination无法工作.

在这种情况下,谁能帮助我使用ColorAmination?



I used ColorAmination to aminate the background color of TextBoxs with c# code.

ControlTemplate worked correctly but ColorAmination didn''t work.

Can anyone help me to use ColorAmination in this case?

推荐答案

嗨.
我有一些空闲时间,我根据您的情况写了这种风格.
看看吧:

Hi.
I had some free time , and i wrote such style which based on yours.
Take a look on it:

<style x:key="Tmp" targettype="TextBox" xmlns:x="#unknown">
			<setter property="OverridesDefaultStyle" value="True" />
			<setter property="SnapsToDevicePixels" value="True" />
			<setter property="Template">
				<setter.value>						<controltemplate targettype="TextBox">
							<grid>
								<ellipse x:name="ellipse" fill="Navy" />
								<contentpresenter horizontalalignment="Center" verticalalignment="Center" />
							</grid>
							<controltemplate.triggers>
			<trigger property="IsMouseOver" value="True">						<setter targetname="ellipse" property="Fill" value="Red" />
			</trigger>						<trigger property="IsMouseOver" value="False">					   <setter targetname="ellipse" property="Fill" value="Navy" />
			</trigger>				</controltemplate.triggers>
					</controltemplate>
				</setter.value>
			</setter>
			</style>


这篇关于TextBox的控件模板的ColorAmination问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆