开发者

ControlTemplate trigger on a subelement

I want to increase the size of the border of a DatePicker when it has focus. In the TextBox style the following works nicely when used with a border BorderBase in the ControlTemplate.

<ControlTemplate.Triggers>
    <Trigger Property="UIElement.IsFocused" Value="true">
        <Setter Property="BorderThickness" TargetName="BorderBase" Value="2"/>
        <Setter Property="Padding" TargetName="BorderBase" Value="3"/>
    </Trigger>
</ControlTemplate.Triggers>

For DatePicker this does not work since the DatePickerTextBox inside the DatePicker has the actual focus. On the DatePicker style page the visual states are listed. The TextBox does have a Focused state, but the DatePicker o开发者_如何学Gonly has a Focused state for when the input invalid.

How do you guys suggest I tackle this problem?


What about setting your Trigger on HasKeyboardFocus instead of IsFocused? I think that one will return true if any child element contains focus


How about naming the TextBox and specifying a respective Trigger.SourceName?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜