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

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.

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.

WPF Adorner Overlay Problem

I am trying to achieve functionality similar to that of a Popup, without using a Popup, but instead adorning my ContentControl with a basic adorner. Basically, I want the ContentControl to have an "overlay" effect, whereby it is the topmost object, above all other elements - similiar to that of the Popup control.
Here is the problem that I am running into, and I am hoping that someone can point out where I am going wrong:
I have a stand grid with two row definitions. The first row contains a UI element - for example, a rectangle. The second row contains a custom control that I have developed to emulate the functionality of a "drawer" sliding out. Basically, when I click on button, I am going to animate a TranslateTransform to "slide" my ContentControl "up". This works fine - except that it gets cropped underneath the rectange in the first row of the grid. If I remove the row definitions in the grid, then when the desired behavior is achieved - the ContentControl is moved "up" and partially "on top" of the rectangle. The rectangle is merely a place holder for what I am trying to achieve. I basically want to have a drawer type control that can slide out and be on top of all other controls.
I am somewhat new to using the Adorner class, so, I am hoping that someone can please point out where I am going wrong.
Thanks.
Chris
Change the parent of the adorner to the full grid, and not just your control. If you put a control in a grid row, and set the adorner to adorn the control, it will usually be clipped to that row because the control is.

TextBox Style issue for Panorama with dark image background

I have a WP7 panorama application that uses a dark image for the panorama's background. The issue is when the device is set to light theme. The issue root cause is the Focus state transition animation for the TextBox sets the background color to transparent.
Since my panorama is always dark I'd like my textbox to always be white background.
First attempt set textbox background to white.
FAIL: transition changes background back to transparent when textbox gets focus.
Next attempt programmatically set textbox background to white on gotfocus.
FAIL: transition changes background back to transparent when textbox gets focus.
Next attempt override control template and change transition.
FAIL: never could get this happy with WP7, not sure if I used right version
Next attempt override control template using Blend 4.
FAIL: might have missed something but every state looked correct.
I see where lots of others are having this same problem but no here's exactly what you need to do so you don't trip up some minor detail.
If you can help us with a solution please do share.
Here's what I tried with Blend 4.
Opened my project in Blend 4, selected my textbox, right-clicked on it, chose Edit Template, and then Edit a Copy.
Here's where I'm not exactly sure what I need to do.
I went to FocusStates, and selected Focused. What I see in the preview pane looks like what I want. A nice textbox with a white background.
I look on http://msdn.microsoft.com/en-us/library/cc645061%28v=vs.95%29.aspx and I see there is a storyboard animation for the various FocusStates and I figure in WP7 there must be one that makes textboxes have a transparent background when they have focus in the light theme.
My goal of making my textbox have a white background since I have a panorama with a dark background image has proven difficult to say the least.
You were on the right path with this retemplating the control in blend. You can control formating of each constituent component of the control and for each state.
If you're still having trouble with this, post your resulting xaml for the TextBox in your question once you've made the changes.
Re your edit: Focused -> Grid-EnabledBorder-Background uses static resource PhoneTextBoxEditBackgroundBrush. You can change this to a local value then choose your colour.

WPF How to animate selection box movement of ListView?

I want to animate movement of a selection box in ListView so it will move from old selected item to currently selected.
I don't even know where to start - could someone please share ideas how to achieve that or it's impossible to do in WPF.
Animate selected item of wpf listbox
Check this. This could give you a start.
After that try animating your border background color to get a virtual translation animation.

Change the position of the textbox validation

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.

Resources