0
我已將style
添加到textbox
,其中我修改textBox
的ControlTemplate
。 我最終爲textbox
擁有不同的control template
。 但我有一個問題。 當我將IsEnabled
屬性設置爲false時,正常的文本框只是greyed
而已。 但具有不同控制模板的仍然是white
。TextBox,不同ControlTemplate + IsEnabled
有什麼具體的我需要添加作爲control template
的一部分,爲了獲得默認行爲?
感謝 桑迪普
更新 - >添加控件模板。
<ControlTemplate TargetType="{x:Type commonControls:DerivedTextBox}">
<Border Name="Border"
CornerRadius="2"
Padding="2"
BorderThickness="1">
<Border.Background>
<SolidColorBrush Color="{DynamicResource ControlLightColor}" />
</Border.Background>
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource BorderMediumColor}" />
</Border.BorderBrush>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="0"
Value="{DynamicResource ControlLightColor}" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="ReadOnly">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="0"
Value="{StaticResource DisabledControlDarkColor}" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOver" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ScrollViewer Margin="0"
x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
我會試試看!謝謝你..再一次你來救我! – Sandepku
我嘗試了顏色,但問題是,我無法匹配默認文本框的顏色方案,是否出現了我所做的錯誤。 ? – Sandepku
我已經用我的模板更新了這個問題,同時邊框在禁用時也有所不同,我沒有線索,關於如何解決這些問題! – Sandepku