WPF RibbonTextBox Width problem

Posted by morsanu on Stack Overflow See other posts from Stack Overflow or by morsanu
Published on 2010-04-02T12:51:13Z Indexed on 2010/04/02 12:53 UTC
Read the original article Hit count: 471

Filed under:
|
|
|

Hey guys,

It seems to me that the Ribbon control has a problem with textboxes. I was expecting a common TextBox control behaviour: a fixed width and a visible caret when the text exceeds the width. But the RibbonTextBox control changes its width and when the text exceeds the right limit, the overflow is not visible.

I found a hack on a blog that does something like this:

var img = SearchButton.Template.FindName("image", SearchButton);
if (img != null && img is Image)
   (img as Image).Visibility = Visibility.Collapsed;
var lbl = FindTemplateControl<Label>(SearchText);

var border = SearchText.Template.FindName("Bd", SearchText);

if (border != null && border is Border && img != null && lbl != null)
{
    (border as Border).Width = SearchText.ActualWidth - (((Image)img).ActualWidth + lbl.ActualWidth);
}

but I reallly don't want to do such a workaround. Is there any other simpler way to achieve simple TextBox behaviour?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about ribbon