Click here to Skip to main content
15,889,544 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm using Material Design ToolKit for WPF. I want to open a dialogue popup by pressing a button.

The button and materialDesign:DialogHost are in the same Grid.
The problem is that when I add Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"> to the button, the button turns pale and gets disabled.
How can I fix this?

What I have tried:

dialogue xaml code:

<pre><materialDesign:DialogHost BorderBrush="{DynamicResource MaterialDesignDivider}">
                    <materialDesign:DialogHost.DialogContent>
                        <Grid Width="300" Height="150" HorizontalAlignment="Center">
                            <StackPanel Orientation="Horizontal" Margin="15">
                                <materialDesign:PackIcon Kind="Folder" Foreground="{StaticResource PrimaryHueMidBrush}" Width="50" Height="50" />
                                <TextBlock Foreground="Gray" Width="200" Margin="15, 5" TextWrapping="Wrap">
                                    Allow application to access data?
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="15">
                                <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignFloatingActionButton}" Margin="4" VerticalAlignment="Center">
                                    Deny
                                </Button>
                                <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignFloatingActionButton}" Margin="4" VerticalAlignment="Center">
                                    Allow
                                </Button>
                            </StackPanel>
                        </Grid>
                    </materialDesign:DialogHost.DialogContent>
                </materialDesign:DialogHost>


button code:

<Button VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="5" Background="#800080" Foreground="AliceBlue" BorderBrush="#800080" Style="{StaticResource MaterialDesignFloatingActionLightButton}" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
    <materialDesign:PackIcon Kind="Pencil" Height="{StaticResource IconSize}" Width="{StaticResource IconSize}" />
</Button>
Posted
Updated 16-Nov-21 7:32am
v4
Comments
[no name] 16-Nov-21 12:11pm    
Do it in "code behind". At least you'll get some useful compiler messages, if any.

1 solution

I found the solution. I put button code inside dialogHost code and worked.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900