How to use Command for SelectionChanged of Pivot control - windows-phone-8

I am using latest version MVVMLight to develop a WP application. I am aware of how to use Command instead of writing code in button click event.
<Button Content='Push me' Command='{Binding DisplayMessageCommand}' />
However, How do i use the Command for SelectionChanged of Pivot control ?
I don't want to write code in SelectionChanged event in code behind .cs file of xaml page.

<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SampleCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>

Related

What is preventing the context menu from showing?

I have an Access database with the following ribbon XML:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" loadImage="LoadImages">
<ribbon startFromScratch="false">
<contextualTabs>
<tabSet idMso="TabSetFormReportExtensibility">
<tab id="tabContextual" label="My Contextual Tab">
<group id="contextualGroup" label="My Group">
<labelControl id="myLabels" label="Sample"/>
<button id="btnDemo" size="large" label="Demo"/>
</group>
</tab>
</tabSet>
</contextualTabs>
</ribbon>
</customUI>
My understanding is that this particular ContextTab will show when a form is opened but I cannot get any ContextTabs to show when I open any form at all.
Is my understanding wrong or is there an error in the XML?
Also, should this code indeed show a ContextTab when a form is opened, how would you show a different context menu for a different form? As I see it, the XML above will open that ContextTab when any form is opened and that appears to be driven by the ribbon so how does the ribbon decide which ContextTab to open for which form (should there be more than one ContextTab defined!!).
Thanks
First of all, make sure that your custom ribbon UI is loaded by the host application. Try to set a breakpoint in any callback and see whether it is triggered or not.
Second, make sure you don't get any UI errors. By default, if a add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. You can use these messages to help determine why a custom ribbon does not appear, or why a ribbon appears but no controls appear. Read more about that in the How to: Show Add-in user interface errors article.

closeOnEscape in Dialog FrameWork PF

In a <p:dialog> there is an attribute called closeOnEscape="true" which allow to close the dialog by pressing the esc key.
I didn't find any similar thing in Dialog FrameWork attributes, according to primefaces documentation.
Is there a way to achieve this using DF ?
Thanks for help.
Look at the Primefaces hotkey component: http://www.primefaces.org/showcase/ui/misc/hotkey.xhtml
This component is a very convenient and helpful way to auto generate javascript which listens for "onkeyup" events.
<p:hotkey bind="esc" handler="PF('myDialogName').hide();" />

Disable the swap in WP8

I'm developing windows phone 8 application.
How I can disable the swap between the items in the pivot page ? since I disabled the IsHitTestVisible property to do that.
But When I used it ; controls in the item page doesn't accept input from user?
How I can disable the swap ? and allow the input from the user in the same time ?
In order to stop the Pivot on WP8 for switching PivotItems, use the new Pivot.IsLocked=true property. Read more about it here # http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.controls.pivot.islocked(v=vs.105).aspx
For example, this code snippet shows how to use Pivot.IsLocked on WP8:
<phone:Pivot IsLocked="True">
<phone:PivotItem Header="Foo">
<TextBox />
</phone:PivotItem>
<phone:PivotItem Content="Bar" Header="Bar" />
<phone:PivotItem Content="Baz" Header="Baz" />
</phone:Pivot>
When you run this code snippet you can see the Pivot only shows the first PivotItem but you can still interact with it (which isn't possible if you simply set IsEnabled=False).
For WP7, use there's a LockablePivot in the Windows Phone toolkit that support this same property. Read more about it here # http://www.windowsphonegeek.com/articles/Windows-Phone-Toolkit-LockablePivot-in-depth

Is it possible to bind a command directly to an app bar button?

I'm creating an MVVM style application for windows phone. With a regular button, you can bind anything that inherits from ICommand to the Command property on a xaml button, like so:
The command property does not seem to exist for buttons in the phones app bar ("shell:ApplicationBarIconButton"). Has anyone figured out how to bind their click event to a Command yet?
It's not possible from the SDK directly, but the AppBarUtils library ( http://nuget.org/packages/AppBarUtils or http://appbarutils.codeplex.com/ ) works nicely.
The codeplex site has example code for different scenarios such as reusing or switching the app bar in a page.
I didn't understand how to use the chosen solution so I went for another one. You just add the library via nuget. It's BindableApplicationBar
Then you just add the following instead of your normal application bar.
<bindableApplicationBar:Bindable.ApplicationBar>
<bindableApplicationBar:BindableApplicationBar >
<bindableApplicationBar:BindableApplicationBarButton
Text="Refresh"
IconUri="/Images/refresh.png"
Command="{Binding RefreshCommand}" />
</bindableApplicationBar:BindableApplicationBar>
It's just a shame that intellisense doesn't reconize the tags. Otherwise, it works like a charm.

setFocus in Flex

I'm Using following code in flex4 mxml That works fine.
<mx:Button label="Set focus to Username"
click="focusManager.setFocus(username);" />
How to use the same in Action script I mean creation complete event of an application without using button.
That is I have login panel in application While page loads the
username field should focused having cursor in it.
Can any one help me?
The issue is that within your application the TextInput has focus, but within the HTML page your Flex application does not. So basically the only extra step you need is to give the Flex app focus. There's only one way to achieve this: through JavaScript. And you should do it after the application was loaded.
The guys at Farrata wrote a very good example on how to do this, so I'm just going to point you there: http://flexblog.faratasystems.com/2011/12/15/setting-focus-in-flex-components