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!
I'm working on an app using IIViewDeck and I only want one view controller to rotate. It's ios 6 and I was able to work out the shouldRotate cascading to get the one that I need to rotate successfully.
My problem is that if I'm in landscape then switch to another view controller, the app remains in landscape. I need to force it back to protestor but I haven't had any success. I thought the simplest approach would be to do some 'force portait' code in the rotatable view controller's viewWillDisapper but I just don't know how to enforce.
Any suggestions?
Your question is also asked here
In all your VC's say yes to rotation, but use an NSUInterger to set the mode like so:
The answer that questions has is below:
-(BOOL)shouldAutorotate
{
return YES;
}
//keep the below code in all your VC's that you do not want to have the rotation capability
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
In iOS 5, my application I used the method to change my orientation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
In iOS 6 I think I'm supposed to do this, but it does nothing! My app is rotated not the way I want it to be.
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
It's how I was adding my viewController.
I replaced this line code:
[window addSubview:viewController.view];
by this line:
[window setRootViewController:viewController];
When the device changes orientation, in iOS 6, the system asks the application which orientation it supports. The application will return a number of orientations it accepts.
How does the application determine it's orientation?
First the application checks it's info.plist orientations (this is very important to determine which orientation to use for launch.
Secondly it asks it's application delegate for it's orientations, this can be specified via the -(NSUInteger)application:supportedInterfaceOrientationsForWindow: method. This effectively overrides the info.plist setting, this implementation is optional. By default iPad apps orientate in all directions and iPhone in all but upside down.
Lastly the application delegate queries it's top most view controller, this can be a UINavigationController or a UIViewController... etc, then it specifies how to be presented and if it wants to autorotate. These UIViewControllers can use shouldAutorotate: and supportedInterfaceOrientations methods to tell the app delegate how to present it.
You must make sure you set the root view controller of your window.
Also if you are presenting any other view controllers in full screen such as a modal view controller, this is the one responsible for determining orientation changes or not.
For me the solution worked, the case was different a bit, because I had a UINavigationController.
My case was that I needed all Portrait window except one. I had to enable all landscape and the portrait orientations in targets (otherwise it crashes on the only landscape view).
So in this case:
create a subclass for UINavigationController,
insert the rotationspecific stuff there
and use the subclass instead of UINavigationController.
If you are using a UINavigationController, it sends the supportedInterfaceOrientations: message to the UINavigationController itself rather than the top most view controller (i.e. what you would actually want it to do).
Instead of having to subclass UINavigationController to fix it, you can simply add a category to UINavigationController.
I created a new variable in my singleton: canRotate, and I set it to YES when I want the viewcontroller to support some orientation.
In appDelegate I added this:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if([[SharedData sharedInstance] canRotate])
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);
}
return UIInterfaceOrientationMaskPortrait;
}
in my case it works. I have a custom tabbar and UINavigationviewControllers are added as subviews to rootViewController.
I know this sounds pretty elementary, but I was wracking my brain to figure out orientation issues while testing on my iPhone - I had the physical auto lock mode in Portrait mode - so nothing I changed programmatically mattered - thought this should be troubleshooting step number 1!
I'm developing a Hex based Game. Having wrestled with the limitations of the C# type system, on discovering Scala I knew I had to rewrite the application in Scala. I need a basic GUI to be able to develop the main functionality. I've been using a WPF Canvas with Polygon class. I also use Wpf Border class and Line class on the Canvas. I don't need most of the functionality of Wpf. I don't use Xaml. i just need to map the graphical objects to the desired coordinates, receive left and right mouse click events from them and put up tool tips and display context menus. I don't even need the Wpf context menu property as as I prefer to the context menus to be dynamic. I handle scrolling and zoom through my own code.
The best that I've found to make Polygons is the awt GeneralPath class. Although this is supposedly depreciated. I've started with Scala Swing, but the MainFrame class will not allow me to use the awt canvas class as content. Any help / recommendations appreciated
just override paint of some Component:
public class MyCanvasPanel extends JPanel{
...
#Override
public void paint(Graphics g){/* do your java2d stuff here*/}
}
I am developing an Adobe AIR application which uses both native windows and floating panels. Is is possible to enable the creation of a floating window instead of a native window when a JavaScript window.open() function is called?
It is required that all of the floating windows are contained within one native window, therefore the creation of more native windows is not suitable.
I have used a Custom HTMLHost class in order to enable the creation of a native window but I can’t work out a way of creating a MDI window instead. I am using the flexMDI framework for my floating panel interface.
Any help on this would be much appreciated.
You can try hijacking the HTML's window object via code:
htmlContent.addEventListener(Event.COMPLETE, htmlLoaded);
private function myOpenFunction(...args) {
// Do stuff with args
}
private function htmlLoaded(event:Event):void
{
htmlContent.domWindow.open = myOpenFunction;
}
I'm not sure if that (or something very similar) will work, but it's probably the only way to do it if it can be done at all.