Why the appbar openes among different pages in flipview? - c#

I am using FlipView control for flipping through various pages i.e. *.XAML pages. I am using ObservableCollection of Page class. Now one page among those pages contains AppBar, but that AppBar can be open in any other XAML page from collection also. How can I prevent the opening of AppBar in all pages ?
Easy Explanation:- I have four XAML pages.
(1) MainPage.xaml (Contains only FlipView and ObservableCollection of Page class)
(2) PageWithAppBar.xaml (AppBar is in this page)
(3) PageWithoutAppBar.xaml
(4) PageWithoutAppBar2.xaml
Now through flipview, when I flip on PageWithoutAppBar.xaml or PageWithoutAppBar2.xaml and press right click then AppBar of PageWithAppBar.xaml become visible so I don't want that thing, how can I prevent that ?
What I have tried till now ?
I have created function to check in which page the AppBar should be visible.
I tried to set
Visibility = Collapsed,
IsOpen = false,
this.BottomAppBar = null,
IsEnable = false
then also it appears

It looks like the Page.BottomAppBar applies to the main container page - regardless of where it is declared. Given this, I'm not sure it is a good idea to use AppBars this way.
Perhaps you may want to create your own control that behaves like an appbar and make it work the way you want? Have a look at :WinRT XAML Toolkit on Codeplex . There is a CustomAppBar control in there, which might work for you.

Related

Accessing SplitView control from a different page than it's host - C# XAML Windows 10 UWP

Pre-warning, I'm new to C# and XAML, but I'm really enjoying Windows 10 UWP apps. I've got a question on how to appropriately handle a SplitView.
I've got a Main Page, in which I have a SplitView control. In the SplitView Content, I've added a Frame for navigation to other pages. I want to add the Hamburger button on the child page to open the SplitView on the Main Page, but I can't access the SplitView control from the child page. How can I make the SplitView control accessible so that the hamburger button within the sub-page can open the SplitView pane?
The alternative is to add a header in the Main Page and have a static hamburger button there, but I don't like this option as it makes handling the text header content more difficult. Another is to copy the SplitView to each page. I don't want to do this either.
Any advice would be fantastic! Thank you.
I would highly recommend you take your alternative option of including the hamburger button in the main page. Users always expect it to be in the same location every time and changing this approach will probably result in a bad user experience.
You also don't want to be repeating code and thus you don't want to recreate the button on every page as well as any additional functionality like the open/close commands.
Rather than referencing elements from one page to another, a better practice is to keep things loosely coupled. This can be done with a messenger plugin which sends an event from one page to the other which can give it instructions on what you want to do. That way the other page only has to listen for the event instead of holding strong references. To streamline some of this process you could inherit from a base class which implements the messenger functionality.
That would provide a solution to your button and your header text situations but setting them up is out of the scope of this question. Depending on the size of you app and your goals, you might like to look into existing frameworks which helps in designing maintainable apps. A good Mvvm framework I would recommend checking out is MvvmCross which also cross platform and contains a messenger plugin.
Good luck with your app.
I found that solution :
In the MainPage, in your SplitView pane button method, add a SplitView reference as parameter in Navigate() :
private void SlitViewPaneButton_Tapped(object sender, TappedRoutedEventArgs e)
{
var frame = contentFrame;
Page page = frame?.Content as Page;
if (page?.GetType() != typeof(ChildPage))
{
frame.Navigate(typeof(ChildPage), SplitViewName);
}
}
In your ChildPage.xaml.cs :
protected override void OnNavigatedTo(NavigationEventArgs e)
{
SplitView sv = new SplitView();
sv = e.Parameter as NavigateControls;
}
You can now do sv.IsPaneOpen = false, in your ChildFrame code.
Note : if you want to pass several Controls, create a Class with these Controls as variables, and use an instance as parameter.
As stated above, it is better to keep your hamburger button in your main page for a couple of reasons. One is the consistency mentioned above. Second, you would have to recreate the hamburger button in each of your content pages instead of just once in the MainPage.xaml. Additionally, keep in mind, there are different kinds of interactions with the SplitView menu in terms of how it pops in and out and how it is displayed, all listed below.
Inline – When the menu pane is opened, it pushes the content over. When it’s closed, the content goes back to its original location
Overlay – When the menu pane is opened, it lays on top of the content. When it’s closed, it is invisible.
Compact Overlay – When the menu pane is opened, it lays on top of the content. When it’s closed, the pane is still visible in Compact Mode.
Compact Inline – When the menu pane is opened, it pushes the content over. When it’s closed, the content goes back to its original position but the pane is still visible in Compact Mode.
You can also see a quick intro into the SplitView here.
http://jamesqquick.com/windows-10-splitview-intro/

Create wizard some clarification

I want to create simple wizard with 3 pages
Page 1 have just next button
Page 2 have next and previous
Page 3 have previous and finish
I have created the pages and add to them needed buttons and in the events I have call to the next pages, for instance in page one in the button click I added the following code
private void Button_Click(object sender, RoutedEventArgs e)
{
p2 = new Page2();
NavigationService.Navigate(p2);
}
In the main window cs I have changed the inheritance to NavigationWindow instead of Window and in the xaml also. Currently its working but I have 3 questions.
The pages which displayed is part of the main window, how can i avoid it, since when I run it the buttons place is not like I put in the designer? It was changed.
The button currently in the Grid, should I put them in different control (the button place should be like any wizard in the left buttom of the page) ?
How can I avoid the navigation arrows in the page right upper screen?
Thanks!
To answer your questsions in reverse,
3. How can I avoid the navigation arrows in the page upper right screen?
I have an opensource library http://winchrome.codeplex.com/ that re-styles navigation windows in several ways. For example these are all NavigationWindow s
In short you just style the NavigationWindow to only show the parts you want.
2.The button currently in the Grid, should I put them in different control (the button place should be like any wizard in the left buttom of the page) ?
If you look at the styles from WinChrome then you will see that it is just a case of rebuiliding the UI as you want and providing a ContentPresenter to hold your pages. e.g. the VS2012 style applies lots of styles on the window but avoids adding back and forward buttons., whereas the Win7 style rebuilds the back and forwards in a Win7 Style.
If you do this however you will need a means of passing your enabled or visible states to the buttons outside the pages. Take a look at http://www.codeproject.com/Articles/8197/Designer-centric-Wizard-control for how to do this in Winforms. In WPF you could either derive from your Pages to create WizardPage classes with CanBack, CanNext or IsFinish properties, or alteratively define attached properties to do the same (There are examples of how to do this in VS2012.cs where we define the glow color)
And finally
1. The pages which displayed is part of the main window, how can i avoid it, since when I run it the buttons place is not like I put in the designer? It was changed.
I'd need to see some code to comment on how you've done it, but if you look at any of the demo programs in WinChrome then you can see how I've done it without problems.
Good luck!

Tab Control tab will only use Wait Cursor

So, I'm making a game in C#, and I've created a window to handle custom controls schemes.
On this page there is a tab Control, with three tabs: Scheme 1, Scheme 2, and Custom
Scheme 1 and 2 are perfectly fine, but on the Custom tab, whenever the mouse hovers over it, it displays the wait cursor. The controls inside the tab work perfectly fine and without lag, but it just always displays the waitcursor.
I can't change the cursor property in the Design window (it just goes back to waitCursor), and I've tried changing it in code, but it won't work.
Please check the following property in your tab control and each tab:
UseWaitCursor set to true
If UseWaitCursor = true for a parent control then it will propagate this property to all child controls. I think this is probably your issue. Please see the link below for an explanation of the property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.usewaitcursor.aspx

Overlapping Window/Page or Custom messagebox?

I want to preface this by saying I'm a noob with WPF/.net programming.
Here is my question that requires a bit of guidance. I have a window and I load pages in and out as my navigation. On one particular page, when the user clicks on one of the items (button for example), I need to display a small form to gather more information. I'm not sure what the best approach is... what I would love (but do not know where to begin even searching for this solution) would be to open a popup balloon style window with a few textboxes and a submit button.
Other options I've explored would be to use a separate page. Save off the current page and load a new page with these textboxes and a submit button. Or to use a custom messagebox instead (least favorite option).
I would like this new extra info page to blend in with rest of the app so that the main page is still visible in the background. Any suggestions??
You can use WPF's Popup control
<Popup>
<!-- Your Content Here -->
</Popup>
Personally I have issues with WPF's Popup, so have my own custom UserControl that works like a Popup.
I ended up using modal window (ShowDialog) method for this.

c# Custom Control Navigation

I have a bunch of Custom Control Forms (i.e. login page, home page, etc.) that I want to be embedded within a "main form". Every time the user navigates to another page, only the content of the "main form" gets changed.
But the only way I can do this is to copy the contents of the Custom Controls and paste them into the "main form" - which is messy. Is there a standard way of doing this type of thing?
Update:
Ok it sounds like possibly you want to use an MDI form or maybe to use user controls (switching out controls for the new pages and such).
Old:
Is it possible you are talking about ASP.net pages and wanting to use master pages?
You might want to use a Panel. Put all the controls for each “embedded form” in a panel of its own. Then you can just show and hide the right panel to make controls appear and disappear.
Alternatively, if you want the user to be able to manually switch between the “pages”, you could consider using a TabControl.

Categories

Resources