简体   繁体   中英

Prevent WPF Textbox from changing appearance when focused

In my custom control I have 2 textboxes. When either one of them is focused, it changes its style slightly... it looses a bit of its border. I would like to prevent this behaviour, which seems to be default textbox behaviour.

Now, I assume that its something to do with the style, possibly with the part of the textbox template

<Setter Property="FocusVisualStyle" Value="{x:Null}"/>

However, is there anyway to prevent this?

@Daniel You have to edit Focussed State StoryBoard . For that edit your TextBox Template for changing the State.If you have Expression Blend it will be easy for you.

您必须编辑默认的TextBox ControlTemplate ,可在此处找到。

  1. You need a control template for your custom control.
  2. In the resources there, you need to style all text box target types. This way, you dont affect regular text boxes.

It would be helpful if you share some code which we can look at/modify to achieve what you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM