I'm not getting to resize my popup

pnet1pnet1 USMember ✭✭✭✭

I did in code behind(Constructor of my popup class)

 public Aprovar()
        {
            InitializeComponent();
            this.BackgroundColor = Color.White;
            this.WidthRequest = 40;
            this.HeightRequest = 40;
        }

but when my popup run nothing happened, my popup remains big yet. How can i do?

Tagged:

Best Answers

Answers

  • pnet1pnet1 USMember ✭✭✭✭
    edited November 2017

    @AdamMeaney, It didn't work.

  • pnet1pnet1 USMember ✭✭✭✭

    The popup occupies antire area of my App. I'd like to resize my popup, See the image below

    Fechar button is inside popup. I putted a frame, but doesn't appear. See my code

    <?xml version="1.0" encoding="utf-8" ?>
    <pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
                 x:Class="Autorizador.Aprovar">
        <StackLayout VerticalOptions="Center" HorizontalOptions="Center" Padding="0" Margin="0">
            <Frame Margin="30" Padding="10" BackgroundColor="AliceBlue">
                <Label HorizontalTextAlignment="Center" FontSize="Large" Text="Hello stilized popup!"></Label>
                <Button 
                HorizontalOptions="End"
                BackgroundColor="Gold"
                HeightRequest="30" 
                WidthRequest="80"
                Text="Gravar" 
                FontSize="9" 
                TextColor="Green" />
                <Button 
                HorizontalOptions="End"
                BackgroundColor="Gold"
                HeightRequest="30" 
                WidthRequest="80"
                Text="Feliz" 
                FontSize="9" 
                TextColor="Green" />
            </Frame>
        </StackLayout>
        <StackLayout VerticalOptions="End" HorizontalOptions="Fill">
            <Button 
                HorizontalOptions="End"
                BackgroundColor="Gold"
                HeightRequest="30" 
                WidthRequest="80"
                Text="Fechar" 
                Clicked="Fechar_OnClicked"
                FontSize="9" 
                TextColor="Green" />
        </StackLayout>
    </pages:PopupPage>
    

    That buttons Gravar and Feliz don't appear and the Lavel too. All are in the frame.

  • pnet1pnet1 USMember ✭✭✭✭

    I don't get to edit my post, then i did a new post, because that post has many errors(english). I'm native in portuguese language.
    The popup occupies entire area of my App. See image below.

    See that there's slightly dark. This slightly dark seems popup is running, but it occupies entire area of my App. The fechar button is in the popup, but the frame doesn't appear. Inside frame i putted two buttons and one label. See that Fechar button isn't in the end, center or start position. The frame doesn't appear. If i touch in the anywhere of the screen, nothing happens. Below my code xaml and cs.

    <?xml version="1.0" encoding="utf-8" ?>
    <pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
                 x:Class="Autorizador.Aprovar">
        <StackLayout VerticalOptions="Center" HorizontalOptions="Center" Padding="0" Margin="0">
            <Frame Margin="30" Padding="10" BackgroundColor="AliceBlue">
                <Label HorizontalTextAlignment="Center" FontSize="Large" Text="Hello stilized popup!"></Label>
                <Button 
                HorizontalOptions="End"
                BackgroundColor="Gold"
                HeightRequest="30" 
                WidthRequest="80"
                Text="Gravar" 
                FontSize="9" 
                TextColor="Green" />
                <Button 
                HorizontalOptions="End"
                BackgroundColor="Gold"
                HeightRequest="30" 
                WidthRequest="80"
                Text="Feliz" 
                FontSize="9" 
                TextColor="Green" />
            </Frame>
        </StackLayout>
        <StackLayout VerticalOptions="End" HorizontalOptions="Fill">
            <Button 
                HorizontalOptions="End"
                BackgroundColor="Gold"
                HeightRequest="30" 
                WidthRequest="80"
                Text="Fechar" 
                Clicked="Fechar_OnClicked"
                FontSize="9" 
                TextColor="Green" />
        </StackLayout>
    </pages:PopupPage>
    

    and my cs code

    [XamlCompilation(XamlCompilationOptions.Compile)]
        public partial class Aprovar
        {
            public Aprovar()
            {
                InitializeComponent();
                //this.BackgroundColor = Color.White;
            }
    
            //protected override void 
    
            protected override void LayoutChildren(double x, double y, double width, double height)
            {
                var maxHeight = 60;
                var maxWidth = 180;
                base.LayoutChildren(x + (width - maxWidth) / 2, y + (height - maxHeight) / 2, maxWidth, maxHeight);
            }
    
            private async void Fechar_OnClicked(object sender, EventArgs e)
            {
                await base.Navigation.PopPopupAsync(true);
            }
        }
    

    I got a small project and ran in my notebook and worked. I copied the code in my App and didn't run. What's wrong in my code? I don't know.
    This code doesn't make nothing, nothing and i don't believe is wrong. Any help is welcome.

     protected override void LayoutChildren(double x, double y, double width, double height)
                {
                    var maxHeight = 60;
                    var maxWidth = 180;
                    base.LayoutChildren(x + (width - maxWidth) / 2, y + (height - maxHeight) / 2, maxWidth, maxHeight);
                }
    
  • pnet1pnet1 USMember ✭✭✭✭

    @AdamMeaney, i'm not getting to do work my popup in my App as you said. Anybody can help me?

  • CharwakaCharwaka INMember ✭✭✭✭✭
    edited November 2017

    Hi @pnet1 ,

    Use the following Grid So that The two buttons will appear,actually your putting to much pressure on UI

    **   <Grid HeightRequest="80" WidthRequest="180">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Row="0" HorizontalTextAlignment="Center" FontSize="Large" Text="Hello stilized popup!"></Label>
                    <Grid  Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button  Grid.Column="0" BackgroundColor="Gold" HeightRequest="30"  WidthRequest="80" Text="Gravar"  FontSize="9" TextColor="Green" />
                        <Button  Grid.Column="1" BackgroundColor="Gold" HeightRequest="30"  WidthRequest="80" Text="Feliz" FontSize="9" TextColor="Green" />
                    </Grid>
                </Grid >
                <Button 
                    Grid.Row="1" HorizontalOptions="End" BackgroundColor="Gold" HeightRequest="30" WidthRequest="80" Text="Fechar"  Clicked="Fechar_OnClicked" FontSize="9" TextColor="Green" />
            </Grid>**
    
  • pnet1pnet1 USMember ✭✭✭✭
    edited November 2017

    @Charwaka, didn't worked. I changed from Rg.Plugin to ContentPage and didn't worked too. I don't know what's happening. What do i want?
    User choose a row in my grid and then press Aprovar or Negar button. When he or she press either button open popup or other thing and user write something in the textbox or textarea and store in the database, only this. I'm having many difficult to do this.
    See below

    When he or she press button would show the popup or other thing.
    I did this way and change PopupPgaes to ContentPage too

    <?xml version="1.0" encoding="utf-8" ?>
    <pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
                 x:Class="Autorizador.Aprovar">
        <StackLayout VerticalOptions="Center" HorizontalOptions="Center" Padding="0" Margin="0" WidthRequest="120" HeightRequest="60">
            <Grid HeightRequest="80" WidthRequest="180">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Row="0" HorizontalTextAlignment="Center" FontSize="Large" Text="Hello stilized popup!"></Label>
                    <Grid  Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button  Grid.Column="0" BackgroundColor="Gold" HeightRequest="30"  WidthRequest="80" Text="Gravar"  FontSize="9" TextColor="Green" />
                        <Button  Grid.Column="1" BackgroundColor="Gold" HeightRequest="30"  WidthRequest="80" Text="Feliz" FontSize="9" TextColor="Green" />
                    </Grid>
                </Grid >
                <Button 
                    Grid.Row="1" HorizontalOptions="End" BackgroundColor="Gold" HeightRequest="30" WidthRequest="80" Text="Fechar"  Clicked="Fechar_OnClicked" FontSize="9" TextColor="Green" />
            </Grid>
        </StackLayout>
        <StackLayout VerticalOptions="End" HorizontalOptions="Fill">
            <Button 
                HorizontalOptions="End"
                BackgroundColor="Gold"
                HeightRequest="30" 
                WidthRequest="80"
                Text="Fechar" 
                Clicked="Fechar_OnClicked"
                FontSize="9" 
                TextColor="Green" />
        </StackLayout>
    </pages:PopupPage>
    
  • CharwakaCharwaka INMember ✭✭✭✭✭
    edited November 2017

    HI @pnet1

    Please change your CS Page code back to

    ** public partial class Aprovar: PopupPage**

    Make sure you creating instance of the popup like this

      private Aprovar _loginPopup;
    
     public MainPage()
    
            {
    
                InitializeComponent();
    
    
    
                _loginPopup = new Aprovar ();
    
            }
    
    private async void OnOpenPupup(object sender, EventArgs e)
    
            {
    
                //var page = new LoginPopupPage();
    
                await Navigation.PushPopupAsync(_loginPopup);
    
            }
    
  • pnet1pnet1 USMember ✭✭✭✭

    @Charwaka, explain me please. You created a new event called OnOpenPopup. In my code i have BtnAprovar_Clicked. Do i create this event(OnOpen) in my code or not?

  • pnet1pnet1 USMember ✭✭✭✭
    edited November 2017

    This way worked, but the Popup still is big, too big. The widht is 640. My app open in landscape mode and i need a popup smaller. I putted this code to resize my popup:

    protected override void LayoutChildren(double x, double y, double width, double height)
            {
                var maxHeight = 60;
                var maxWidth = 380;
                base.LayoutChildren(x + (width - maxWidth) / 2, y + (height - maxHeight) / 2, maxWidth, maxHeight);
            }
    

    The grid appear inside this dimension, but entire area still is with slightly dark and i don't get click in the grid behind the popup. I'd like show a small area with popup and around is a free area, without popup what isn't happening. If i change background color to white or other color, the grid behind the popup hide, miss. Doesn't appear, doesn't show. My App start in Landscape mode.

  • CharwakaCharwaka INMember ✭✭✭✭✭

    Hi @pnet1

    Why don't you add a button and in click handler call close popup code as I shown ??

  • pnet1pnet1 USMember ✭✭✭✭

    Ok, i was that possible by button inside popup. Is bad this popup and i don't know other popup. With this plugin i'm unsafe. I didn't like.

  • CharwakaCharwaka INMember ✭✭✭✭✭

    Give me sometime i will post solution for this

  • WarwenczackWarwenczack BRMember ✭✭

    Já tentou utilizar essas propriedades no binding ?
    Acho que isso pode resolver o problema pra ti...
    xD!

  • pnet1pnet1 USMember ✭✭✭✭

    Hi,

    @Warwenczack ,

    How can i do this?

  • WarwenczackWarwenczack BRMember ✭✭

    Hi @pnet1 if you don't know how to do it,
    faster and easier is use the property Margin in your Popup passing a new Thickness();

  • pnet1pnet1 USMember ✭✭✭✭
    edited November 2017

    My popup area still too big. See the screenshot. I putted two buttons and one Edit.

    When i write in two or more lines, only the botton line appear.

    and see how is it

    I created a click event and when i press button doesn't work. The App just stop.

  • NMackayNMackay GBInsider, University mod

    You probably need to make the popup Background transparent and then make your control in the popup position itself with a solid background. You seem to want an editable popup but I've picked through all these posts and I don't know what your trying to achieve.

    You do not give us enough information to help, it's frustrating as we're trying to help!

  • pnet1pnet1 USMember ✭✭✭✭

    @NMackay, i gave you all information. If you want more information, i'll give you, but what kind information do you want, please? I'd like to resolve this problem and i'm doing better. I posted code, xaml, screenshot. If is missing somethig, please tell me.

  • CharwakaCharwaka INMember ✭✭✭✭✭

    Hi @pnet1

    Please take a look at https://github.com/XAM-Consulting/SlideOverKit simple and better

  • WarwenczackWarwenczack BRMember ✭✭

    @pnet1 said:
    My popup area still too big. See the screenshot. I putted two buttons and one Edit.

    When i write in two or more lines, only the botton line appear.

    and see how is it

    I created a click event and when i press button doesn't work. The App just stop.

    If you're using an entry, you can set a property HeightRequest="100" with the height that you need.
    I think that this will solve your problem.

  • pnet1pnet1 USMember ✭✭✭✭

    I setted to 60. Maybe my great problem isn't know to communicate as well. I'm not getting make me understood. I know this site is to solve problem in english and maybe be this my problem. English.
    @Warwenczack, eu quero apenas isso. Um popup pequeno, que tenha um Edit dentro e dois botões. Um para ok, que envia para um REST o texto inserido e um cancel para voltar e nada acontecer. Apenas isso e não estou conseguindo transmitir isso com meu péssimo inglês. Não consigo um simples popup pequeno, de dimensões reduzidas, mas meu cliente disse que isso não é mais importante e isso me preocupa, tipo você não está conseguindo, deixa pra lá. Isso não é bom para os negócios.

  • WarwenczackWarwenczack BRMember ✭✭

    @pnet1 said:
    I setted to 60. Maybe my great problem isn't know to communicate as well. I'm not getting make me understood. I know this site is to solve problem in english and maybe be this my problem. English.
    @Warwenczack, eu quero apenas isso. Um popup pequeno, que tenha um Edit dentro e dois botões. Um para ok, que envia para um REST o texto inserido e um cancel para voltar e nada acontecer. Apenas isso e não estou conseguindo transmitir isso com meu péssimo inglês. Não consigo um simples popup pequeno, de dimensões reduzidas, mas meu cliente disse que isso não é mais importante e isso me preocupa, tipo você não está conseguindo, deixa pra lá. Isso não é bom para os negócios.

    ah, saquei...
    Ta criando um Popup, mas ele não parece um... isso ?

  • pnet1pnet1 USMember ✭✭✭✭

    yes, it isn't seem like popup.

  • WarwenczackWarwenczack BRMember ✭✭
    edited November 2017

    @pnet1 said:
    yes, it isn't seem like popup.

    When you use: await Navigation.PushPopupAsync(new MyPopupPage());
    this create a kind of mask behind your Popup, are you using this method to create the Popup ?

  • pnet1pnet1 USMember ✭✭✭✭

    Yes, i am. How can i create a popup not be that way. How?

  • pnet1pnet1 USMember ✭✭✭✭

    I'd like a popup like DisplayAlert like this below. Only with Edit inside it and two buttons, OK and Cancel. Ok send text to REST and Cancel to cancel.

Sign In or Register to comment.