Material.Avalonia icon indicating copy to clipboard operation
Material.Avalonia copied to clipboard

PopupBox Implementation

Open Tenjim opened this issue 4 years ago • 11 comments

Hi guys,

Just a question, do you have any implementations of PopupBox from Material Design ? I'm using it and I wanna to know if there is any implementations ingoing for material.avalonia ?

Thanks in advance.

Tenjim avatar Aug 11 '21 15:08 Tenjim

Hello, @Tenjim

If I understand you correctly, then what you want is implemented in DialogHost.Avalonia: previewGif

Soon I think I'll be integrating this package into Material.Design, but for now it can be delivered and used separately.

Does this solve your problem?

SKProCH avatar Aug 12 '21 09:08 SKProCH

Hi @SKProCH,

It's a button that open a content with others controls in it. It's not a other window poping like DialogHost.

PopupBox

Tenjim avatar Aug 12 '21 10:08 Tenjim

@Tenjim, you can use, for example, ToggleButton and Popup controls like this:

<ToggleButton Name="MyToggleButton" HorizontalAlignment="Center">Toggle me</ToggleButton>
<Popup IsOpen="{Binding #MyToggleButton.IsChecked}"
       PlacementTarget="MyToggleButton"
       PlacementMode="Bottom">
  <styles:Card>
    <TextBlock>Your popup content here</TextBlock>
  </styles:Card>
</Popup>

Popup + ToggleButton

SKProCH avatar Aug 12 '21 11:08 SKProCH

@SKProCH , Thank ! I'll try it to check if it complete my need :)

Tenjim avatar Aug 12 '21 11:08 Tenjim

Hi @SKProCH,

Just to clarify what we need. It's a control from MaterialDesignInXamlToolkit. https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/wiki/PopupBox

Tenjim avatar Aug 13 '21 07:08 Tenjim

@Tenjim, We don't have one out of the box at the moment.

We will try to implement this control as early as possible, but I do not know when it will be, because the main team of contributors is currently busy at work. If you want, then you can implement this (or something else) by yourself and create a PR. They are warmly welcomed.

SKProCH avatar Aug 13 '21 08:08 SKProCH

@Tenjim, seems like this is already implemented via Menu control:
Анимация Is this what you were looking for?

SKProCH avatar Aug 14 '21 17:08 SKProCH

@SKProCH, not really because I want to put an usercontrol on the popup content like your first example.

I want to put a usercontrol which have many Buttons/ ComboBox/ CheckBox/... like into the Card

example :

<PopupBox  IsEnabled="True">
       <control: CustomUserControl>
</PopupBox>

CustomUserControl.axaml:

<StackPanel>
            <TextBlock x:Name="Label"
                       VerticalAlignment="Center"
                       Text="{Binding Label}">
            </TextBlock>
            <CheckBox 
                  IsChecked="{Binding IsCheck}"
                  Name="CheckBoxTest1"/>
</StackPanel>

It's what I want to do with PopupBox.

Tenjim avatar Aug 16 '21 13:08 Tenjim

Hi @SKProCH,

Finally, I have done a workaround with your advice (Togglebutton with popup) :

<Style Selector="buttons|PopupBox">
      <Setter Property="Template">
        <ControlTemplate>
            <Grid>
                <ToggleButton Name="toggle" IsEnabled="True" HorizontalAlignment="Center" IsChecked="{Binding #StandardPop.IsOpen}">Click me</ToggleButton>
                <Popup x:Name="StandardPop" IsLightDismissEnabled="True"
                       HorizontalOffset="0"
                       VerticalOffset="10"
                       PlacementTarget="toggle"
                       IsOpen="{Binding #toggle.IsChecked}">
                    <styles:Card
                        Name="CardPopup"
                        FontSize="15"
                        FontWeight="Regular"
                        Padding="10"
                        Margin="5">
                        <ContentPresenter Content="{TemplateBinding Content}" />
                    </styles:Card>

                </Popup>
            </Grid>
        </ControlTemplate>
      </Setter>
  </Style>

Tenjim

Tenjim avatar Aug 17 '21 09:08 Tenjim