How to render different pages in 1 WPF window - c#

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.

Related

Button seems to animate instead of the others

Here is my UI structure in the Hierarchy:
And here is how it looks:
So basically, when I click the first button, its color changes on click as expected. However when I click the second or the third one, the first one also displays the click animation, instead of the one I clicked.
Here are some things I noticed:
The buttons do register a click as expected.
When animating the button further than the default (by using custom timeline animations) the behavior is slightly different between the first and the second + third ones.
Things to note:
I am using a horizontal layout group on the panel with the following settings:
Each button has a TMP image inside with the same size as the button itself.
I theorize that the HLG is the problem here, but I've tried many settings and the result stayed static.
If you need any additional information, please ask.
Turns out the problem was that the target graphic on the buttons were all set to the first one. That's why they still registered the click properly even though the visuals were messed up.

How to unload menus (UIViewControllers)

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)

windows store app page blank when navigating to it

I have 3 pages in my application.
First page: 5 Buttons, each navigates to different page (currently, only the first button works).
Second page: Back Button and ListView, the ListViewItems are UserControlItems with Button, Image and TextBlock. When you click on the Button (of the UserControlItem) it Navigates to the third page, which is Media Player Page with alot of controls.
Third page: Media Player page with alot of controls such as MediaElement, Slider, Buttons and more
When I navigate from Third Page to Second Page using the Back Button, sometimes the screen stays black (the color of the theme) and sometimes it loads too much time. In addition, the ListView has visible vertical scrollbar (always) which is not shown unless you move your mouse on the ListView.
How to fix these problems?
EDIT 1:
link to my project - put some .wmv/.mp3/.mp4 files in the Videos Library folder.
EDIT 2:
I investigated the black page issue abit more and I found that the MediaElement is the cause.
The MediaElement stores the stream and it slows the computer.
In order to resolve to problem, when you click on the GoBack Button, it first set the source of the MediaElement to null, and only when the MediaElementState == Closed, I go back - seems to solve my problem (since I applied the solution I didnt experience more black screens).
About the scrollbar - I think I'll be able to solve it if I simulate MouseOver over the ListView - no idea how to do it
Ok Ill List out the issue one by one.
List View Scroll Bar : Since we are developing for a potential touch surface so scrollbars are not meant to be visible every time.
Blank Page : When you press the back button then Big page Ie third page gets stored in the forward navigation property of the history element. Additionally all the resources that were being used in the third page is disposed. So the time taken to go to second page becomes huge.
Please try havig a fourth page which will have less controls. And see if any Black background issue is occuring or not. It will give a better and clear picture.
--- Update Code for permanent visibility of scroll bar---
Please download the code for listview styling from
Listview styles
add your code to the project
and replace all FadeOutAnimation By FadeInAnimation.
This was the quickest I could do for a solution. For a Better one you can always play with the styles.
Ohh one more thing please add
Style="{StaticResource ListViewStyle1}"
To your list view. please try and let me know.

Disable NotifyIconOverflowWindow autohide

I have done flyout window similar to win7 battery meter. It is behaving just like built in one except when it is shown via notify icon who is located on NotifyAreaOverflowWindow aka notify overfow area that window autohides itself after some time while it should hide only when my flyout closes. The only difference that I could spot with spyxx that after some time overflow window simply sends itself an WM_SHOWWINDOW wp:0 lp:0 message.
How can I prevent the overflow window from autohiding while my flyout is active?
Image 1: Test flyout shown after click on notify icon which is located on overflow area + couple seconds of user inactivity.
Image 2: Battery meter flyout shown by clicking on notify icon which is located in overflow area + 2 mins of user inactivity.
You should call
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPSTART, Handle, OBJID_CLIENT, 0);
before you show your window and call
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPEND, Handle, OBJID_CLIENT, 0);
after you hide it.
Flyouts are no different from any other window.
If I'm understanding your problem, which is that the windows disappear over time, then the solution is quite simple. Do not use whatever NotifyAreaOverflowWindow is. Instead, create your own window, with the appropriate properties (no control box, no max/min buttons, no title text, etc...). Because it's likely out of your control to set the duration of the class/object you're using. It's likely designed for single-notifications, and not something moderately useful ;).
Plus, you'll be able to do fancy things as desired without running into anymore issues.
The following tutorial goes in great lengths on how to position it so perfectly:
http://blog.quppa.net/2010/12/09/windows-7-style-notification-area-applications-in-wpf-part-3-taskbar-position/

Which WPF Layout and Controls Should I Use for a Storyboard Effect

I want to create a layout that has small panels at the top and bottom and then a main panel in the center that fills the remainder of the window. The main window should have the functionality of a tab panel but instead of simple tabs I want the tab pages to slide on and off the screen. It will be like one large storyboard that slides back and forth and only displays one scene at a time.
So lets assume there are 4 tab pages. Initially the first page will be visible, the 2nd page will be directly off the screen to the right, the 3rd page will be 2 pages off the screen to the right and the 4th page will be 3 pages off the screen to the right. When the user clicks to see the 3rd tab page the layout will slide left 2 pages. Then if the user clicks to see page 1 again, the page will slide back right 2 pages.
The window needs to be resizeable, so I can't use fixed sizes and offset.
Do I just need to use a StackPanel and programmatically set width, height, and position or is there something built-in that I can use?
Hrrrm the first idea that comes to mind is use a ScrollViewer and hide the ScrollBars.
You could then display all your items in a StackPanel in the ScrollViewer, and when you want to scroll an item into view, simply animate the ScrollViewer's position so it smoothly scrolls to the specified item.

Categories

Resources