Change the position of the textbox validation - silverlight

The new data validation in silverlight 3 has a red textbox that flies out to the right. This is a problem for me because I have have a textbox to the right that is getting covered by the popup.
How can I make this popup move somewhere else?

Retemplate the textbox. The tooltip is found in there. You can modify it using the placement property or margins to appear elsewhere.

Related

How to get an existing property from style

I'm developing a WPF project where I need to validate textboxes on code-behind and then change the border color of those textboxes to some unknown color defined by the user configuration; the problem is that to overwrite the MouseOver effect I would need to set the value from XAML directly via ControlTemplate or Style.
Is there a way to get the current value assigned to the TextBox from XAML? Maybe binding it to itself?
I will appreciate any help you can give.
When validating a TextBox, or any control for that matter, it's common to use an adorner to display the validation error (in your case, setting the border color). You can have a look at an example here.
Using this method, you don't actually change the TextBox's border, but create a new visual layer on top of the TextBox that draws the new border around it. This is pretty much the way validations should be done in WPF, and it also solves your problem of having to deal with changing the TextBox's border value back and forth.

How to adjust placement for tooltip with callout in WPF

I am customizing the tooltip on my user control so that it looks like a callout. The tooltip is set to appear above the control (Placement=Top) with an arrow pointing down toward it.
The problem is when the control is near the edge of the screen, the tooltip is not aligned to the left-side of the control. As a result, the arrow points to an empty space to the left of the control.
Even worse, if the control is near the top of the screen, the tooltip shows up below the target control and the arrow pointing down.
Any idea how to resolve this? I am looking for some way to programmatically create the tooltip on the fly or set a trigger to select the Style based on some properties in the tooltip but I don't know how.
I have faced the same problem in the past and what I did was get the position of the PlacementTarget via PointToScreen(new Point(0,0)) and get the position of the ToolTip by calling the same method and then doing the math to figure out whether the ToolTip is correctly positioned or not. If it wasn't, then I changed the Placement of the ToolTip according to whether it was showing up to the left, right, above or below the PlacementTarget. Also, keep in mind, that PointToScreen() will only work once the ToolTip has rendered so attach a handler to ToolTip.Open and do it in there. Hope this helped. Let me know if you come across a more efficient/better way to solve this problem.

Issue with IDataErrorInfo with text box in Expander

I have one expander and which contain text box, text is validating through IDataErrorInfo, it is working fine when i enter wrong information, it popup with red rectangle.
but issue arises when i tried to collase the expander, and red rectangle is still there. it stayed on Expander
so please provide soem good solution....
Another solution is to create a control template where you wrap the contentpresenter element in an adorner decorator. This prevents the validation escaping the closed expander.

Control focus styling

in above image you would notice that, doted rectangle indicating ComboBox is focused
But the problem is it exceeding the text area of ComboBox... how do I align it with text area WPF Style?
Thanks
Without seeing your ControlTemplate it's difficult to give the best way to change it.
One slightly hackish way to do it is set Focusable on the ComboBox to False and then set Focusable on the TextBlock (or Label) to True. This should make it so the TextBlock gets focus whenever the ComboBox should.
My best guess though is that you have some weird margins going on, the real way to fix it would be to straighten those out.

How do I remove the focus rectangle from a silverlight textbox control

Does anyone have any ideas on how I can remove the focus rectangle from a silverlight textbox? (I'm talking about the blue rectangle that appears when you click on the texblock to start typing)
I'm looking through the default style and template for the textbox but can't seem to figure out which element to tweak.
Thanks!
In the template you will find a border called FocusVisualElement. In the base and Unfocused Visual State it has an opacity of 0%. In the focused Visual state it has 100% opacity. You can simply delete the FocusVisualElement if you don't want any border indicating the focus.
This probably looks weird when the MouseOverBorder still appears so you might want to delete that too from the Template, however move the ContentElement it holds to the parent Grid first.
Alternatively you could set the Opacity to 0% for these borders in all states.

Resources