更改windows phone通用应用中内容对话框按钮的样式 [英] Change the style of content dialog button in windows phone universal application

查看:27
本文介绍了更改windows phone通用应用中内容对话框按钮的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 xaml 中定义了这个内容对话框:

I have this content dialog box defined inside my xaml:

    <ContentDialog x:Name="AlertMessage" Background="#363636" IsSecondaryButtonEnabled="True" SecondaryButtonText="Cancel"  IsPrimaryButtonEnabled="True" PrimaryButtonText="Ok" >
        <ContentDialog.Content>
            <StackPanel Name="rootStackPanel" Height="Auto"  >
                <StackPanel Margin="0">
                    <StackPanel Margin="0,0,0,10" Orientation="Horizontal">
                        <TextBlock x:Name="HeadingText" x:FieldModifier="public" Style="{StaticResource ApplicationMessageBoxHeadingStyle}" Text="Alert"  />
                        <Image Margin="10,05,0,0" Source="/Assets/Images/alert.png" Width="35"></Image>
                    </StackPanel>
                    <TextBlock x:FieldModifier="public" x:Name="ContentText" Style="{StaticResource ApplicationMessageBoxErrorStyle}" Text="Are you sure you want to log off ?" />
                </StackPanel>
            </StackPanel>
        </ContentDialog.Content>
    </ContentDialog>

我是这样称呼它的:

private void AppBarButton_Click(object sender, RoutedEventArgs e)
    {
        MessageBox();
    }
    private async void MessageBox()
    {
        ContentDialogResult LogoutDialog = await AlertMessage.ShowAsync();

        if (LogoutDialog == ContentDialogResult.Primary)
        {
            this.Frame.Navigate(typeof(MainPage));
        }
        else
        {
            // User pressed Cancel or the back arrow.
            // Terms of use were not accepted.
        }

    }

问题:是我的应用程序中的所有按钮都有一个样式.我也想对那个对话框的主要和次要按钮应用相同的样式.我无法弄清楚如何实现这一目标.是否可以将样式应用于这些按钮?

Problem: is that my app have a style for all the buttons in my applications. And I want to apply same styles to the primary and secondary buttons of that dialog box too. And I am unable to figure out how to Achieve this. Is it possible to apply styles to these buttons?

推荐答案

ContentDialog 按钮不可自定义,但您可以不设置 ContentDialog 的主要和次要按钮并在模板中添加您自己的按钮.

The ContentDialog buttons aren't customizable, but you can leave the ContentDialog's primary and secondary buttons unset and add your own buttons within the template.

这篇关于更改windows phone通用应用中内容对话框按钮的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆