VisualStateManager with Windows Phone 8.1 BottomAppBar - windows-phone-8.1

I'm using VisualStateManager in a Windows 8.1 app to update the visibility of buttons on the BottomAppBar...
However this same XAML appears to not be supported for the BottomAppBar on Windows Phone 8.1.
When I attempt to update a button in Blend I get the error: An animation is trying to modify an object named '', but no such object can be found in the PageStandIn.
Is there a way to make this work or will I have to use code-behind to toggle the visibility manually?
is there any way to make this work so I can share the code from win81 to update the command bar?

The AppBars are very special, they are part of the System UI (in some sense) and thus somethings tend not work as expected.
Using storyboards don't work for updating them.
You can use the code behind, but if you are using an MVVM framework you should be able to Bind them to a Boolean and using a BooleanToVisibilityConverter to do the visibility management.
Model
public bool ShowAppButton {get; set;}
View
<AppBarButton x:Name="MyAppButton" Label="AppButton" Visibility="{Binding ShowAppButton, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
Hope this helps!

Related

How to disable touch gestures on SciSurface modifiers

I have WPF MVVM app. On one screen I'm using SciChartSurface and in some case I need to overlay it with dialog. Problem is, that SciChartSurface modifiers are responsive even thru another grid overlaying whole SciChartSurface. Is there any way to disable this touch gestures catching without disabling modifiers?
Thank you
In SciChart WPF v4 & 5 you can disable touch interaction by setting the flag to false.
public static bool MainGrid.RegisterTouchEvents { get; set; }
This will prevent all touch input processing for all SciChartSurfaces in the application.
Is this the desired outcome or did you want something else?

is it possible to pin AIR app over any opened windows?

I need to pin AIR application over other windows, I mean, regardless if AIR application is in focus or not, it must not hide, it always must be shown, whatever other program I activate or work with, AIR application must be over every window always. Is it possible? If it is, please show me the function (example code will be better :) ) which does it, incase if AS3 has one.
You're looking for the alwaysInFront property of the NativeWindow class:
The alwaysInFront property specifies whether this window will always be in front of other windows (including those of other applications).
The following example forces a window to be displayed in front of all
other windows (that are not similarly forced to the front):
windowObj.alwaysInFront = true;
Another example with a reference to a display object on the window stage:
displayObject.stage.nativeWindow.alwaysInFront=true;

Bind TreeView.SelectedItem to a property in the ViewModel in a WinRT app

In my Windows Store XAML app I’m using the TreeView control from the WinRTXamlToolkit and I’m attempting to two-way bind the SelectedItem property to a property on a ViewModel.
Out of the box, the SelectedItem property is read only and this makes sense because the control supports Virtualization.
I have seen some folk work around this with things like attached properties, helper methods and so forth, a great example of which is seen in this question
WPF MVVM TreeView SelectedItem
But all of the questions/solutions are not based on WinRT and all of my attempts to rework the solution code for a WinRT app have proven fruitless.
So, my question is, is this possible in a WinRT app? What am I missing?
Thanks
I'd skip trying to come up with a bindable property globally for the view model and instead use the IsSelectedBindingPath and IsExpandedBindingPath properties of the TreeView as in the debugging tools' example of the control's usage. Then when you want to select/expand an item from the view model - use a method similar to SelectItem() in my view model where I essentially set IsExpanded/IsSelected to true in item/node view models throughout the path from the root of the view model tree and load the content of the tree if the nodes in the expected path do not exist.

When I navigate to a view, how do I link a viewmodel to it?

I have a basic MVVM light Windows Phone 8 app created. I have MainView, being shown as the startup page. This is automatically getting the datacontext of a new instance of MainViewModel.
I want to navigate to another view, and have a new viewmodel (or an existing one provided on navigation) set as the datacontext for that view.
How do I do this?
I have navigation working through http://mvvmlightnavigation.codeplex.com/SourceControl/latest#MVVMlightNavigationService/NavigationService.cs
Should I be using something else for navigation?
In the basePage tag in XAML
you can add your view model like this
<basepage:BaseApplicationPage
DataContext="{Binding YourViewModel, Source={StaticResource Locator}}">
Make sure the you have to registered the ViewModel with the same name that you are giving in the data context.
I am using MVVMlight, so ViewModel and View are registered in the 'ViewModelLocator'.
Hope this helps

How to bind caliburn.micro view model to WP8 LongListSelector control?

Is there a way to automagically bind a Caliburn.Micro view model to the Windows Phone 8 LongListSelector control and auto-wire the SelectedItem property?
If i understand your question correctly, then you want normal Caliburn.Micro conventions to be applied to the LongListSelector control.
I don't work with Windows Phone development but i think it can be done by calling the following line of code in the Configure() method of the bootstrapper.
ConventionManager.AddElementConvention<LongListSelector>(LongListSelector.ItemsSourceProperty, "SelectedItem", "SelectionChanged");
This code tells Caliburn.Micro to use the ItemsSource property whenever it a finds a named (e.g. x:Name="myList") LongListSelector and to use the SelectedItem whenever a LongListSelector element is passed in the parameter list of an action message, and finally it uses the SelectionChanged event to fire action messages by default.