kikipoulet / CherylUI

MIT License
248 stars 8 forks source link

InteractiveContainer not found #1

Closed Petrarca181 closed 11 months ago

Petrarca181 commented 12 months ago

Hi was testing your controls. I'm facing a problem.

MainWindow

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="using:ARapportini.ViewModels"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:views="clr-namespace:ARapportini.Views"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="ARapportini.Views.MainWindow"
        Icon="/Assets/avalonia-logo.ico"
        Title="ARapportini"
        xmlns:controls="using:CherylUI.Controls">

    <controls:InteractiveContainer>
        ... your App ...

    </controls:InteractiveContainer>

</Window>
 public MainWindow()
 {
     InitializeComponent();
     MobileNavigation.Push(new MainView());
 }

Here it works fine and navigates to the MainView, but when I try to navigate from MainView to the Page2 I get the following error.

image

kikipoulet commented 12 months ago

Well, being able to test the code would help.

Otherwise I think using it in the constructor is kind of weird. My documentation is probably not clear enough but I personally use the base content directly in xaml, like this

<controls:InteractiveContainer>
      <MainView />
</controls:InteractiveContainer>

and remove the MobileNavigation.Push in the constructor of MainWindow. (Of course for "children" page I then use the C# navigation)

If you really want to use it C# behind at this point, use "OnLoaded" instead of the constructor, because the problem is that the view isn't loaded yet even if you call it after InitializeComponent, so like this

 public MainWindow()
    {
        InitializeComponent();

    }

    protected override void OnLoaded(RoutedEventArgs e)
    {
        MobileNavigation.Push(new MainView());
        base.OnLoaded(e);
    }
Petrarca181 commented 12 months ago
<controls:InteractiveContainer>
      <MainView />
</controls:InteractiveContainer>

this still not works, but adding InteractiveContainer to the MainView(first landing page) actually fixes everithing.

I have another aquestion. How to properly setup page transition effects for your navigation system? I'm preaty new in avalonia, but documentation is preaty dry and there is any real sample :(

kikipoulet commented 12 months ago

Yes, if you are developping for Mobile by the way, it's normal that MainWindow does not work.

About transitions between page when Push or Pop, I have to modify ContentControl to TransitioningContentControl (https://docs.avaloniaui.net/docs/controls/transitioningcontentcontrol)

It already works, but there is an issue in Avalonia that "corrupts" the page when using the transitioningcontentcontrol making it blank or deformed, and it happens too often to be usable.

https://github.com/AvaloniaUI/Avalonia/issues/9387 https://github.com/AvaloniaUI/Avalonia/pull/11326

I'm following these issues because as soon as it's solved, I can change the contentcontrol to a transitioningcontentcontrol and add automatically a nice transition when changing page.

Petrarca181 commented 12 months ago

Thank you. I will wait for updates.

kikipoulet commented 12 months ago

Thank you. I will wait for updates.

Actually maybe I won't use transitioningcontentcontrol because I think that 'push' and 'pop' should have different transition. I work on a custom navigation transition for the next update.

navigationtransition