I'm working on an app with which I send and receive data from and to a database.
At the moment, when I start the app in portrait or landscape position, it will always display the first menu in portrait style. When I turn the first menu, it switches to landscape just fine. I have properties in my AppDelegate to store screen width and height.
Whenever I navigate to another menu for the first time, it takes the screen width and height from the AppDelegate to draw the new menu. Every menu I navigate to does this perfectly.
The problem is, that when a menu is already loaded, I switch to another menu, turn the screen and go back to the previous menu, the layout is still in the previous screen mode. For example:
I start the app and get to the first menu in portrait mode. The values for screen width and height in the AppDelegate will change to the current view.bounds.
I navigate to menu #2 for the first time. Menu #2 will use the screen width and height in the AppDelegate to draw the menu.
I navigate to menu #3 for the first time. Just like Menu #2, it takes the screen width and height from the AppDelegate to draw the menu.
I turn the menu from portrait to landscape. Menu #3 will redraw and change the screen width and height in the AppDelegate to the new values.
I navigate back to menu #2, but it's still drawn as if it were in portrait mode.
Is there a way to unload the menu (that's not the obsolete method of "WillUnload" or "DidUnload")? Or is there a method that gets called every time I navigate to a menu that I already loaded in my memory?
I love to hear from you.
Love and regards,
Björn
viewWillAppear: method gets invoked every time the controller's
view is about to be displayed. Whenever you make a transition to and
fro from a controller, it would be invoked.
From Apple's documentation(iOS Developer Library) :
This method is called before the receiver's view is about to be added to a view hierarchy and before any animations are configured
for showing the view. You can override this method to perform custom
tasks associated with displaying the view. For example, you might use
this method to change the orientation or style of the status bar to
coordinate with the orientation or style of the view being presented.
If you override this method, you must call super at some point in
your implementation.
An another lifecycle method that you can use is viewWillLayoutSubviews. You can read more about it here.(iOS Developer Library)
Related
I'm using NavigationView in a UWP project that contains a Frame to load pages.
When the windows is small enough the NavigationView Pane is automatically closed only showing the Icons of the MenuItems, if the Menu is specifically opened (clicking the top button) the menu overlaps the pages inside the frame (this happens after a given threshold, when the Window becomes smaller)
I was trying to maintain this behavior all the time (instead of only when the window is resized to small values), even if the window is maximized or is resized to large values.
isPaneOpen appears to be a read only property that does not work at Run time.
The overlap (rather than pushing the frame to the right) I don't know how to get this NavigationView display all the time...
Any help how to do this?
Thank you.
As your description, it seems you want to maintain the NavigationView always in the Compact mode, you can implement this effect by overriding the widths at which the navigation view changes display modes using the CompactModeThresholdWidth and ExpandedModeThresholdWidth properties.
You can try to configure your NavigationView as the following code,
<NavigationView CompactModeThresholdWidth="280" ExpandedModeThresholdWidth="2000"/>
You can set any CompactModeThresholdWidth property value smaller than the minimum default UWP app window width and the ExpandedModeThresholdWidth property value larger than the maximum window width.
More details, please see the NavigationView display modes topic.
I want to emulate modal dialog in XAML Metro App.
So I was going to set .IsEnabled = false on all controls apart from the one which will pose as a modal dialog.
Apparently IsEnabled not in Grid not in Panel not in FrameworkElement. How to disable it not making a user control out of it?
I guess Sinofsky cut so many corners that the whole thing is now more like an Escher staircases. I am loosing my faith. Please help
Sorry, I am a little late to the party...
Here is how I created a modal popup - I used a popup dialog where the top and bottom portions are transparent so that anything behind it will show through. When the popup is opened, I set its size to cover the entire screen.
The top and bottom portions of the popup also are set to autosize (height = *), so that they fill up the entire top and bottom of the screen. This prevents any input from going into the grid underneath.
Here is a screen shot of my popup in Visual Studio:
The popup is a grid with 5 rows, 3 for the dialog itself and 2 for the transparent top and bottom.
Here is how the popup looks in my app. Obviously the grid shows through the transparent top and bottom. Since the popup fills the entire screen, any input (keyboard or mouse) goes to it rather than the grid underneath, making the popup act like a modal dialog.
Be warned though that with this strategy, you have to handle these events:
Screen resizes (full screen, snapped view, filled view) - you need to resize the popup to fit within each of the view states
Screen rotation - again, you have to handle resizing here
Keyboard popup - you need to shift the popup up so that the onscreen keyboard does not interfere with it.
Set IsHitTestVisible = false on the background content.
Additionally you could set focus to something in your modal layer root and set TabNavigation to Cycle on the modal layer root to make sure that users can't tab/shift+tab out of it. Also make sure the modal layer is all hit test-solid - e.g. Transparent or has some other fill so users can't click through it.
Also make sure no Popups show while your modal layer is visible.
Unfortunately no one seems to know (except Mr Skakun who gave wrong answer and never bothered to revise it).
Hence my solution (the simplest) is to make the element in question Hidden - I cant find any other ways to 'disable' a grid.
If I wanted to disable it correctly I would have to write a recursive function to find all FrameworkElements in the grid children and set IsEnabled = false though.
I have a view and within the view, there are two user control, each with a button on it. When the page loads, the first user control will load. when i click on the button in the first user control, I would like to slide the first user control left, making it invisible and display the second user control. when i click on the button in the second user control, I would like to slide the second user control right, making it invisible and displaying the first user control again. can anyone help on how to achieve this?
If I get correctly, you want something like Carousel in wpf. In case that's it, here's the link. It allows you to slide several items left-right to switch between them.
Another way to go would be using default animations in WPF, meaning DoubleAnimation applied to Margin property that increases margin from 0 to 500 (to move it off the screen) and back to 0 (to return it) or something like that. Head's up for double animation and moving controls is here and official documentation here.
Rather than hard-code an animation designed for your specific scenario, you could do something a little more generic and adapt the TransitionControl that uses pixel shaders. Set the content property and you can specify which shader effect you want it to apply as the transition.
I am currently having issues with rendering different screens in 1 window (only 1 screen displayed in the window at a time).
The solution i want to achieve in my WPF application:
1 Window (all screens must be within the same screen)
3 different screens
when something is selected on the 3th screen (button), the first screen shows up again
The first and the second screen were loading up successfully but i was unable to open the 3th screen. Since then i have been trying several things but was unable to come up with a solution.
The application structure looks like the the following:
Main Screen (With a button) --> When clicked on the button 2ndscreen replace the 1st screen. The 2nd screen holds yet another button, when clicked shows the 3th and final screen.
I cannot seem to be able to open this 3th page.
What i have tried so far without any success
navigation window (redirection with the navigationService always yields a null exception)
frame (when i open the second frame the content of the first frame is still there, a refresh or content clear did not work to render only the second screen).
Best regards.
I've created an application that display a topmost window on each monitor, to cover all available place.
Then, I would like to allow to draw a rectangle on the windows. So, I create a rectangle that I add to the window when mouse move and mouse click ...
This is working except when I'm drawing a rectangle that starts on a window and finish on another one. Of course, because it's not the same window ...
How can I do to allow drawing on both window at the same time ?
Thanks for your help,
You can create a window that stretchs across both screens.
Use the Screens collection in System.Windows.Forms (or wherever it is in WPF) and the WorkingArea property to calculate the correct extents of the window.
Be careful with multi monitor setups where primary screens are the other side from secondary screens or if the screens are stacked on top of each other.
We do this successfully in our application.
Another (and probably better) approach to this would be to have the data about the rectangles stored in a model class (using a MVVM approach). Then each view looks at a separate part of a virtual canvas. This way they both listen to updates of the data from the model and draw their section of the display accordingly.