ListPicker separate templates for Normal and Expanded states - windows-phone-7

Is is possible to either subscribe to a ModeChanged event or to have a separate template for the Normal and Expanded states of the ListPicker control.
I am specifically looking for a way to have my text wrapped when the ListPicker is expanded (not full-screen) and not wrapped when the ListPicker is in the Normal state.
I am using this in a Windows Phone 7.1 targeted application and the GotFocus, LostFocus, and Tap events are not being fired. Right now, the only event I can look at is the SizeChanged event to look at switching templates by looking at the ListPickerMode status.

The ListPicker supports 2 separate templates, one for each scenario.
Use ItemTemplate for the expanded view.
Use FullModeItemTemplate for the full page view.

Related

What difference does it make if I use the SearchBar control versus the Entry control to search a ListView?

Regarding Xamarin.Forms, I've been reviewing the Entry control documentation along withe the SearchBar control documentation. After reviewing the documentation for both, they appear to be similar.
What difference does it make if I use the SearchBar control versus the Entry control to search a ListView?
I think they are functionally similar but the key difference in SearchBar is that you get different visualization and keyboard at least on iOS and Android. The Enter button has a custom icon or text and there is an icon in the entry field. Images of different devices can be found here. You can also see images of SearchBar on Android here:
The Entry when rendered is just a Textbox, using this for search is possible but you will need to manually add a search button (if needed), cancel mechanism and attach yourself to the events to make the search. In the other hand using the SearchBar all this is already part of the control, out of the box for you.
If you don't need this extra functionality or you don't mind having to rewrite it you can use the Entry otherwise go with the SearchBar.

After assigning GetViewForAnnotation, Xamarin.Forms class doesn't receive Click event

I have a Xamarin.Forms page with a map containing numerous pins. I've built a custom iOS renderer to change the image of the displayed pin.
Once I assign the GetViewForAnnotation delegate, my Xamarin.Forms class no longer receives the "Clicked" event. I can access it through the custom renderer, I do believe, but what I want to do when the user taps the title of the pin is push another Xamarin.Forms page to the navigation stack, and I don't know how to give control back to my Xamarin.Forms app from within my Xamarin.iOS app.
I have a feeling I'll need this type of logic in a few other places... where I need to handle a CustomRenderer event but then pass control back to the Xamarin.Forms app for navigation or other purposes.
So I have a couple directions I'd like to go:
1 - More straightforward - get my "Clicked" event to fire in the Xamarin.Forms app when the map's pin is clicked, even though the iOS app is handling the creation of the pin via a CustomRenderer
2 - More advanced and customizable - pass control back to my Xamarin.Forms app (maybe raise an event related to the Renderer level?)
I'd prefer at this time to just get my Clicked event back, but I'm guessing that may not work once I assign the GetViewForAnnotation event in the CustomRenderer.
From what I read, you can detect the annotation click within your renderer.
Within your renderer in the OnElementChanged you can get access to the View in the Xamarin.Forms PCL it relates to.
A few possibilities to consider going forward:-
a) Use MessagingCenter to convey messaging between interests (see
here).
b) Use the standard event raising, i.e. public event
EventHandler<someEventArgs> OnSomeEvent through your View in your
PCL.
c) Use an ICommand approach on your View in your PCL if your
more MVVM orientated, and invoke this way instead.
Once you have your notification back through your View / Page, depending on where your doing things, you can then do a normal navigation based on the information you have been given from your platform-specific renderer in the PCL.

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.

How to call a c# method from javascript in window phone 7?

I want to detect swipe in web browser control in C# using JavaScript. I want to add some JavaScript to my web content and then if swipe occurs, call a method that loads another web content in the same web browser control.
I would like some sample code or any other suggestion to do this.
Thanks in advance
You'll need to use something to detect the swipe in javascript. I've been recommended to use touch.js but haven't had a chance to try this yet.
When you detect the swipe you can call out to native code using window.external.notify().
Be sure to set IsScriptEnabled="True" on the WebBrowser control and register an handler for the ScriptNotify event.
It's this event handler which would load the new content.
First of all, consider that gestures for a webbrowser control have it's own handlers. Now, if you don't need to pan/zoom or the like in the webbrowser control, it's not a problem.
Then you simply set the IsHitTestEnabled attribute to false, so that the web-browser no longer receives input. Then you can simply use the GestureService from the Silverlight Toolkit to handle the swipe/flick inputs.
I wrote some code on how to handle this, in another question: wp7 horizontal swipe selection

Can't access the Application buttons from c# (Windows Phone 7)

I'm writing a Windows Phone 7 app and want to programmtically access my Application bar buttons when the page loads. But these always appear to be null. I've tried accessing the button in the following events:
Page Contructor (after call to InitializeComponent)
Page's `Loaded' event handler
The Application Bars StateChanged event handler
There don't appear to be a Loaded event on the individual buttons either. Am I breaking the rules here? Why can't I access the application bar buttons with c#?
When I looked at this in one the CTPs, it was possible to access elements as I outlined in this thread.
Cannot change ApplicationBar items in code
Note that access to Application Bar elements is available through the type rather than the instance as you might initially expect.
Peter Torr clarified soon after that the Application Bar isn't quite a first class citizen in the framework. Explained here in more detail for your reference.
Why are the ApplicationBar objects not FrameworkElements? - Peter Torr's Blog
To localize the button text, in the page's Loaded event handler, I've been iterating over the page's ApplicationBar.Buttons list and replacing the value in the button's Text property with the resource translation. Seems to work, even if it's kludgy.

Resources