MAUI Shell + TabbedPage - c#

I have application based on Shell. Application contains pages with tabs which are deffined in Shell. Everything works properly and correctly.
I need create second level page with tabs whitch contains options for return to previous page. In the case of standard "ContentPage", "Routing.RegisterRoute" and "Shell.Current.GoToAsync" it is no problem. However, if I create a TabbedPage like this, my application ends with exception:
0xFFFFFFFFFFFFFFFF in Android.Runtime.JNIEnv.monodroid_debugger_unhandled_exception
I am aware of this information:
TabbedPage is incompatible with .NET MAUI Shell apps, and an exception will be thrown if you attempt to use TabbedPage in a Shell app.
However, I am not sure if this also applies to the second level page, or only to pages that are directly referenced in Shell.
How can I create second level page with tabs?
Is there anyone who has encountered a similar problem, or someone who can give me advice?
Thanks a lot

Using shell, you are limited to content pages.
Navigating to such page is not a problem. Calling GoToAsync will give you the "second layer" you request.
The more interesting part is how to implement tab control, so you have tabs in that ContentPage.
One way to solve this is by using BindableLayouts.
(Here is a good example: https://dev.to/davidortinau/making-a-tabbar-or-segmentedcontrol-in-net-maui-54ha)
You can make really neat UI with this.
It will be worth your time.
Ask if you have any questions.

You can combine TabbedPage, FlyoutPage and NavigationPage instead of shell if you really want to create second level page with tabs. Obviously shell is based on flyouts and tabs, so if you use FlyoutPage and TabbedPage alone in your project, it will be more flexible and troublesome than the shell.
These are the documents about the specific use of FlyoutPage and TabbedPage, you can refer to them if you need: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/pages/flyoutpage?view=net-maui-7.0 and https://learn.microsoft.com/en-us/dotnet/maui/user-interface/pages/navigationpage?view=net-maui-7.0.
Hope this will help you.

Related

Prism for Xamarin.Forms unable to AutoWire

I am trying out Prism.Forms for my next client project. Unfortunately, I am seeing a strange behavior with my samples.
Pretext
It seems like XF or Prism does not like me including an existing XAML page (also mentioned by Brian Lagunas - The man - himself at the Evolve session). But renaming a page also throws it off and the ViewModelLocator can't seem to locate the ViewModel anymore. Even if I re-create the page with same name, It can't find it ViewModel. Manually setting the BindingContext works, but I am trying not to create my dependencies for constructor injection.
Question
While working on existing code, a minor change caused NullReference exception when using NavigationPage as a root. Here is an example of a working sample app
https://github.com/hnabbasi/xamarin/tree/master/XFPrism/XFPrism
I am using a NavigationPage and pushing a ContentPage. Then I push another ContentPage, then I show a Modal page via button click and communicate. I send parameters back to Second content page via NavigationParameters.
To break it, simply try to swap the ISayHello service with IPageDialogService. I am not sure what's going on that's breaking it.
Thanks in advance :)
The INavigationService is a named type and as I recall a known limitation of Unity is that named types must precede unnamed types.
As mentioned by Dan S. in the comments. The MainPage is not set when I was calling the PageDialogService to display the alert, hence the NullReference.
In case you really need to do something like this where you want to somehow wait for something to finish before doing an operation, try Task.Yield().
I fixed my scenario as below,
// will yield for current operation of page appearing
await Task.Yield();
// by now, the page has appeared and set, so this should work fine
SayHiCommand.Execute(this);
I have used this workaround in the past. If you know a better way of handing this, please comment away.

How do i add another components on the MainWindow?

Struggling, I need a button to open up a window but below the MainWindow in C#. Like in a website you can open other pages but the master page layout doesn't change only the page you are viewing shows differently.
I need similar thing. I have components (tools i added from toolbox) on my MainWindow.xaml so for example if i click on a button i named new student, a tabbed-window where i can capture student details must appear but it must not be a separate windows it must appear within the mainwindow and seem like a one thing. Forgive for my English. I hope someone will understand me though, thanks in advance. I want to have components/functionality according a specific button click but constant Mainwindow, the one with "File" "Edit" "View" "Help".
There are a couple different solutions to you problem, but Visual Studio doesn't quite have something like the Master View option through ASP .NET with webforms.
Option One
Using TabControl. This option is the easiest solution to your problem. The GUI in Visual studio has support for adding components to each tab, which nothing else has. This is the closest component to something like multi-panels in Java, but it will still create the Tabs, which may not be what you are looking for.
Option Two
Using multiple Panels over one another. With this option, you can add multiple panels to your main window and layer each panel over one another. You can add a button or other control which will hide each panel and all of its contents. This is a great solution if you don't want tabs, but it can be frustrating to create in Visual Studio since you must move each panel away from another in order to add/remove/adjust the components on the underlying panel.
Of course there are still a few more controls you can use to produce the results you are looking for, but these are probably the most applicable solutions to your problem.

Multiple Content Page Control Windows Phone 7

I've been searching on the web for a little while for a content control for Windows Phone 7 with multiple pages, where I would be able change content by changing the index, something like a PageControl or a TabControl, but without the tabs, but I had no luck.
The Idea is to give the user multiple views for the content, but I don't want to use the pivot since it will be inside a pivot item. It can't be scrollable.
I would give the user the view options, and the control would show the option he chose.
Does anyone know any kind of control that can do this kind of thing?
Thanks in advance.
You could use a UserControl and just switch the views on that single page. You would have to plumb your own implementation you want. But the controls should be extensible enough for it to be have your own custom implementation there on how it will work.
I would also suggest to go to this MSDN Documentation and check the inheritance of UserControl.
More specifically, to make it easier for you check Caliburn Micro to make it easy to switch content in a single page. Hope it helps!

Windows Forms Browser Skeleton (C#/.NET)

I was wondering if anyone knows of an existing sample or an approach to achieve the desired functionality.
Basically, what I'm looking for is a web browser like skeleton. The idea is that the main screen of my application is shown in the left tab. This tab can never be closed. On this screen is an overview of various application components such as activities, events, contacts, etc.
When the user clicks on a specific contact/event/activity a new tab is created and auto-focused. The user can view and edit the information. When they are done they can close the tab.
The ability to have multiple tabs open is important.
Also, keyboard shortcuts to easily navigate between tabs would be great, but not absolutely essential at this point.
Note: I don't need to access any web content.
Really what I'm looking for, at least what I think I'm looking for, is a shell of a modern web browser. Does something like this exist? Is there a good approach to building such an application?
Note: I'm new to Windows GUI development, so I apologize if this is a rudimentary question. I was unable to find anything meaningful while searching MSDN and other resources.
Thanks!
What it sounds like is not really a Web Browser shell at all, simply the relative appearance of one functionality-wise.
What you can do is use a TabControl control. This can be altered to suit your needs quite perfectly in my view.
An example of a modified TabControl is as follows: [ From here ]
There are a number of things that can be done with a TabControl (as with any other component) to make it suit what you need.
Here are some links that you may find helpful:
Flat Tab Control - As per the picture
MSDN
Video on using a Tab Control
C# Corner

Effectivly creating a tabbed website with RadTabStrip

I have an ASP.NET web application that I am making and I am thinking of making it a tabbed interface using Telerik's RadTabStrip. I am trying to figure out the best way to approach this though. I would need about 10 tabs because I have about 10 different main areas of my application. My question is how is the best way to integrate the content into the tabs. All of the simple examples I've seen create RadViews with imbedded HTML/ASP.NET content. The problem with this approach is that, with 10 tabs, it would make my main ASPX file really really big and it would be kind of clumsy to work with, having to integrate all 10 pages into one page. Is there a better or more accepted way to accomplish this?
I think, you have several possibilities:
Use one RadTabStrip and several RadView controls. Put the content for each tab into a separate user control (*.ascx). Then you only have to include the user controls in your main aspx page.
Use a master page and put the RadTabStrip on it. Create a separate page for each area of your application (each using the same master page). Use the RadTab's NavigateUrl property to navigate to the corresponding page (as shown in this demo).
there are certainly other possibilities...

Categories

Resources