1

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
  • 471
  • 5
  • 28

3 Answers3

1

@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.

asitis
  • 3,023
  • 1
  • 31
  • 55
  • I've not got expression blend, but looking at the default TextBox ControlTemplate I can't find the Focussed State Storyboard... i guess I'm really missing something crucial here? Is this storyboard in TextBoxBase? Or do I just set a new one? In any case, thanks for your answer so far – Daniel Feb 15 '13 at 10:00
  • 1
    here's a question about where/how to find the default theme contents: http://stackoverflow.com/questions/3548319/where-can-i-find-the-default-wpf-control-templates – John Gardner Feb 18 '13 at 20:06
  • Ok, I see how it works, is there any easy way of removing a focussed state storyboard? Or do I overwrite it? So, I see the visual states for the TextBox control in http://msdn.microsoft.com/en-us/library/ms752068(v=vs.100).aspx do I just define the Foccussed state again? (Sorry if this question may show a lack of WPF knowledge) – Daniel Feb 19 '13 at 07:40
  • Ok, got it, if I just leave out the Focussed state storyboard in the TextBox style, then it will not change (which, in retrospect makes a lot of sense). Thanks a lot – Daniel Feb 19 '13 at 10:36
0

You have to edit the default TextBox ControlTemplate which you can find here.

Dummy01
  • 1,985
  • 1
  • 16
  • 21
0
  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.