本文介绍了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?

推荐答案

<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问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 03:34