Silverlight button background image change while switching button State - silverlight

I am having an issue about buttons in silverlight on windows phone 7. My button has a background image, and as I press it, it goes white like all the buttons in wp7 by default. What I want it to do, is to change its background image to different one. I found topic that describes something quite similar, but regarding the button color Windows Phone 7 (WP7) Change a button's background color on click.
Problem is that whenever I adjust any of the basic styles (Pressed, Disabled etc), I can only change everything besides the background image, because when I change it for one style, it stays changed for all the rest of them.
How can I make button change its background image while going into Pressed state? And why cant I do it the way the above link says?

ImageButton for Wp7 http://silvergeek.net/2011/01/14/imagebutton-control-for-win-phone-7/
If its not exactly what you need it might give you some hints.

Related

Replicate default mouseover background color when a button is pressed

I am building a wpf ribbon application. When certain buttons are clicked on, I would like the background to remain "lit up" like when the mouse is over it. I don't want to change the default mouseover color, I just want to replicate it when the button is pressed for "modal" type commands. Is there a way to do this? In MFC programming it would be like adding the "BS_PUSHLIKE" style to the button where it remains lit while active. Thanks for any help you can provide.
I am not sure exactly what you are looking for, but I believe the equivalent of "BS_PUSHLIKE" in WPF is the ToggleButton control.

Image Button with no border that works like a toolbar button?

I want a button that
Displays an image with NO border, NO background, NO text
If I tab into the imagebutton, THEN it shows the background and border
Also if I hover over it, it shows the background and border
I've searched and I've tried so many different things, but nothing it exactly what I want. I've tried setting various properties on the button to make the background and border transparent, but it still shows up. I've tried a style with a custom control template. I'd rather not have to completely reinvent all the triggers etc to get the button to render on mouse over. The biggest problem with custom control template is that then I loose all existing functionality and I'm basically building a new control from the ground up.
Here is another link that came closest to what I wanted but it doesn't properly work for me.
How do you completely remove the button border in wpf? - BUT.... for some reason the hover effect gets stuck. One I mouse over the image and the button border draws, it stays stuck on until I click somewhere else.
Actually, you will want to override the control template. You're not "losing" any functionality (aside from the UI triggers).
Original/Default Template -- This is a good starting point... copy/paste that into you're XAML (wherever you want to style this button... ie Button resources, UserControl/Window resources, App Resources?). From there make your adjustments.
Another easy way is to use Expression Blend. You can easily create a new template based on the existing template, and the styling/authoring tools it provides are much better than hand-coding XAML (unless you're good at doing that).
As far as displaying an image instead of text, just set the image as the content. A Button is a type of ContentControl which means that it can house any type of content (Object).

WPF Windows 7 Lock Screen Buttons

In Windows 7 (and Vista, if I recall correctly), when you hit CTRL+ALT+DELETE it takes you to a pre-lock screen such as the following:
I am looking to find a way to recreate the buttons on this screen (Lock this computer, Switch User, etc.) for an app I am working on. I need to be able to specify what the left-hand side image is since all of mine won't be arrows. Does anyone know where I can find a style that mimics how this looks/behaves?
Also, if there is a way to also come up with a button style that mimics the Cancel one that would be awesome.
Follow this tutorial and you should get the cancel button style. And for the other buttons you can create a button ControlTemplate with a StackPanel containing Image and TextBlock.

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.

Can I get GroupBox ForeColor to behave the same as Button in WinForms?

I am expecting the text on GroupBox caption and Button caption to be the same color if they have the same ForeColor (as well as other controls set similarly).
The ForeColor property of a GroupBox and several Buttons are each set to ControlText, but they render as blue (groupbox) and black (buttons). Assuming these match the current XP Theme. The question is how do I set the properties on these controls, or Winforms controls generally, such that their behavior is consistent and expected? Or is it correct already and I am misunderstanding?
That's not in general how theming works. It overrides the default properties of controls according to the user selected theme. A more stark example is ProgressBar.ForeColor, it's going to be the pulsing green bar on Vista, no matter what color you select in the designer.
Fwiw, there's a fair amount of pain you can get into when you try to override this. GroupBox.ForeColor is a very notable example. It is only going to have the theme color (it is faked btw) if you never assign ForeColor yourself. Once you do, you can never reset it back. Even if you assign ControlText again you'll get black, not the theme color. This is somewhat inevitable from the way 'ambient properties' are implemented in Windows Forms. Calling it a bug would not be unjustified. Not tinkering with it is the best way to avoid this trouble, your user isn't going to be complaining.

Resources