Button Skinning in Windows Phone 7 - windows-phone-7

I have created a derived button class which contains a couple ImageSource members for the Normal and Pressed states. I need to be able to change the image to the Pressed image whenever the user presses the button.
Looking around I've noticed that you can use VisualStateManager in xaml to specify the bitmaps to use for each state. Windows Phone 7 (WP7) Change a button's background color on click
Now this is all fine and dandy, but I need to be able to do the same thing dynamically rather than at design time. Is there a way to do this in code?
Or can I override some event handler and set the background manually? Seems that there are no event handler to trap this and it's a no-no from what I read...
Thanks!

You can try the following:-
In the ManipulationStarted event handler you can change the image-source to the pressed image.
In ManipulationDelta event handler check if the button is not pressed then change the image to the normal one.
Finally in ManipulationCompleted event handler change the image to the normal one.
Hope this helps...

Have you tried setting images for each state as properties in your control?

Related

Custom button not displaying in Today Extension

I have some custom buttons in my host app that I'd like to use in the Today Extension.
They work just fine in the app but do not display in the widget.
The button on the left is my custom button class, the one on the right is a UIButton. If I change it to my custom class it too disappears.
Any thoughts why this might be happening?
----------------------EDIT------------------------
Well, somehow I managed to get it to display but sometimes it's not drawing the whole button and sometimes it's drawing the button incorrectly.
Any help would be appreciated! Thanks

How to check if tapped region falls inside a PopUp Control

I am using tap event listener from wp toolkit. In my app I show a pop up screen. I have defined the gesturelister to work on the Grid. In capturing the Tap gesture event, I get the screen coordinates (i.e X and Y) where it happened.
Now i want to know if the Tap happened inside the PopUp control or outside it. How can i achieve this on wp8. I have tried many solutions but none seems to work. Please help on this.
Is the Grid under or over the PopUp Control?
If yes, the solution is pretty simple.
When the click is on the Popup the Grid will not receive it.
When the click is not on the Popup the Grid will receive it.

WinRT Settings Charm. Elements overlayed by on screen keyboard

I'm developing for Windows 8 (WInRT) and have problem with settings charm. Settings popup is based on Microsoft SDK settings charm. Settings panel is Popup. Content is wrapped by ScrollViewer -> Grid -> StackPanel. In StackPanel I have input fields. when I trying to fill last of them on screen keyboard overlaying it and I cant see field and cant scroll to it. Is there any way to see it and to scroll to it automatically?
Seems like the popups on Windows 8 suffer from the same problem as they did on Windows Phone in that when you put a TextBox on one of them - it does not get pushed up together with all the other content as it does when it is not in a popup.
My solution to that would be to not use popup for input fields and instead go for a layout that you can manage yourself.
By default the app has a Frame control at its visual root. You can modify it for example by putting your own UserControl in there (I usually call it AppShell) which has the Frame used by all pages, you can have a layer for popups, log in screens, the extended splash screen etc.
To solve your problem you would need to put your charm's UI inside of such layer instead of in a popup. Then the build-in mechanism that pushes all the UI up when the on-screen keyboard would otherwise obstruct the view of your TextBox should just start working again.
*EDIT
A simpler solution might be to make sure your settings panel popup is parented in your visual tree - e.g. by adding it as a child element to a root grid of your app or page. It turns out that in that case its content does get pushed up when the OSK shows up.
Take a look at this post
It's a popup wrapper (turns user controls into popups) that takes care of the keyboard appearing and adjusts the size of the popup (and thus the user control) accordingly.

WP7 slider drag end event

I'm developing a WP7 music player. I use the slider to track the playing progress.
I want to allow user to drag the slider to seek a certain posion within the track, but find no drag end event?
The slider_ValueChanged event doesnot satisfy my need.
I follow the instruction here WPF: Slider with an event that triggers after a user drags but it doesnot work on WP7
Please help
I follow the instruction here using Manipulation Completed Event, and it works

windows phone mango - differences between click and tap

Can anybody give me more details on this?
I know that tap is coming from gestures, but I'd like to know more on WP7 events model.
For instance how following scenarions work:
stackpanel with tap event and checkbox inside which handles click
container with tap and any framework element also with tap, etc.
Which events have more priority and if is it possible to mask events?
What kind of event bubbling is used here from top to bottom or vice-versa?
If you're using WP7.1 SDK the easiest thing to make things consistent would be to use the Tap event everywhere (it's available on all UIElement derived controls). Tap events are bubbled up from the lowest control in the visual tree until a handler is found.
Then you don't need to worry about if/when Click and Tap will clash.

Resources