WPF metro扁平化UI 控件及对话框

WPF界面 metro使用笔记(1)

本文只介绍Metro对话框的两种使用方式,。该控件库的安装及引用可参考

https://blog.csdn.net/lurifan/article/details/60955686

添加引用

using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;

使用metrowindow可直接使用

using MahApps.Metro.Controls.Dialogs;
    public partial class MainWindow : MetroWindow
    {
        private async void DialogsBeforeExit()
        {
            var result = await this.ShowInputAsync("Hello!", "What is your name?");
            if (result == null) //user pressed cancel
                return;
            await this.ShowMessageAsync("Hello", "Hello " + result + "!");
        }
    }

wpf风格窗体+Metro

public partial class Window1 : Window
{
        public async void ShowMessageDialog(object sender, RoutedEventArgs e)
        {
            var metroWindow = (Application.Current.MainWindow as MetroWindow);
            await metroWindow.ShowMessageAsync("Hello!", "What is your name?");
        }
}

**注意:对话框使用异步方式。


你可能感兴趣的:(WPF metro扁平化UI 控件及对话框)