Coder Social home page Coder Social logo

Comments (7)

jessejiang0214 avatar jessejiang0214 commented on August 11, 2024 1

Well As SlideOverKit doesn't have bindable properties for show and hide popups, so it means you cannot control it from ViewModel.

But there is a solution for that, in FreshBasePageModel you can use this.CurrentPage property to get current page, then convert current page as MenuContainerPage, then call ShowMenu();

from slideoverkit.

tallmanBS avatar tallmanBS commented on August 11, 2024

I'm not sure what it means when you say
then convert current page as MenuContainerPage, then call ShowMenu();

How is this done?
I've tried in the buttonclick of the model
public Command buttonClicked { get { return new Command(() => { var page = this.CurrentPage as MenuContainerPage; page.ShowMenu(); }); } }

    But this is not going to work.  I also cannot change the ContentPage to MenuContainerPage

public partial class TestPage : ContentPage
Because it's a partial class and the generated code also refers to it as a ContentPage.

How would I get the MenuContainerPage built?

Thank you for your help as I think others have needed this as well. I really like slideoverkit and hope I can use.

from slideoverkit.

jessejiang0214 avatar jessejiang0214 commented on August 11, 2024

You TestPage must inherit from MenuContainerPage or IMenuContainerPage, otherwise you cannot use SlideOverKit.
Here is the document http://www.xam-consulting.com/slideoverkit-xamarin-forms/

from slideoverkit.

tallmanBS avatar tallmanBS commented on August 11, 2024

I've brought in all the renders into my project as the document specified, and the classes. Where I'm stuck is I've built my own MenuContainerPage as follows using the FreshMvvm Base.
public class FreshMvvmMenuContainerPage : FreshBasePageModel, IMenuContainerPage, IPopupContainerPage {
But because the FreshBasePageModel doesn't have a Page base, I can't get it to call the renderer when i execute the ShowPopupAction.

I can grab the Page from CurrentPage in FreshBasePageModel, but I'm lost on how to connect it to the renderer without having MenuContainerPage be the base. I know I'm doing something wrong, but not sure what.

from slideoverkit.

tallmanBS avatar tallmanBS commented on August 11, 2024

I am happy to have some progress so I'll post here in case someone else finds this and its helpful. So to have the popup show inside my Model and ModelPage was alot simpler than I thought.

  1. I changed my ContentPage on the Xaml.cs to
    ` public partial class TestPage : MenuContainerPage
    {
    public TestPage()
    {
    InitializeComponent();
    PopupViews.Add("FirstPopup", new PopOverView());

     }
     public void OnClicked()
     {
         ShowPopup("FirstPopup");
     }
    

    }
    `

  2. Changed the Xaml using sample provided for SlideOverKit and
    `
    <local:MenuContainerPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp.Pages.TestPage"
    xmlns:local="clr-namespace:MyApp.Classes.SlideOverKit;assembly=MyApp" >

    <ContentPage.Content>









    </ContentPage.Content>
    </local:MenuContainerPage>`

This allowed the page to operate. Then if I wanted to open the popup from inside the model, I just changed the button onclicked to use the command and included.
` public Command buttonClicked
{
get
{
return new Command(() =>
{

                var page = this.CurrentPage as MenuContainerPage;
                page.ShowPopup("FirstPopup");
        }
    }

`
Although after more consideration, I think generally this would mean the view logic of the popup would be in the model, and should be in the xaml.cs as part of the view. Regarldess.

I did not pursue making the popup actually use a model/view. I think this would be too much work for the amount of use this will have. For just the couple screens, I decided just to not use model phylisopy for the popup.

from slideoverkit.

jessejiang0214 avatar jessejiang0214 commented on August 11, 2024

You can create a Bindable property in xaml.cs file, and then binding this property with ViewModel, like ShowPopup, when this property changed you can show or hide the menu from XAML code behind.

from slideoverkit.

ernestochaves avatar ernestochaves commented on August 11, 2024

I tried adding a property. #79 but I'm stuck on knowing why it isn't building for me. Also, I noticed a bunch of PR from jessicarich1980 that never got merged, so I assuming mine won't be accepted either anytime soon.
But you can probably do what I did, subclass the container page and add the bindable property. I am using it that way and it works.

from slideoverkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.