如何在使用Caliburn.Micro设置的应用程序中设置“窗口/应用程序”图标 [英] How do I set a Window/Application icon in a application set up with Caliburn.Micro

查看:67
本文介绍了如何在使用Caliburn.Micro设置的应用程序中设置“窗口/应用程序”图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我缺少明显的东西。但是,由于我的应用程序的主窗口是由

I think I am missing something obvious. But since the main window of my Application is a UserControl that is being launched by

protected override void OnStartup(object sender, StartupEventArgs e)
{
    DisplayRootViewFor<MainWindowViewModel>();
}

在我的引导程序中,如何设置窗口本身和

in my bootstrapper how do I set the Icon of the window itself and of the application in the toolbar?

推荐答案


  • 基于XAML的解决方案 :将您的 MainWindowView 基类从 UserControl 更改为 Window ( (在.xaml和.xaml.cs中),然后直接在xaml中设置 Icon 属性或任何其他特定于窗口的属性。

    • XAML based solution: Change your MainWindowView base class from UserControl to Window (both in .xaml and in .xaml.cs), then set your Icon property or any other window-specific properties right in xaml.

      基于代码的解决方案 DisplayRootViewFor< T> 采用可选的设置参数:

      Code based solution: DisplayRootViewFor<T> takes an optional settings parameter:

      var settings = new Dictionary<string, object>
      {
          { "Icon", new BitmapImage(new Uri("pack://application:,,,/WpfApplication2;component/icon.png")) },
          { "ResizeMode", ResizeMode.NoResize }
      };
      
      DisplayRootViewFor<IShell>(settings);
      

      键应与要设置的窗口属性相对应,并且值类型必须匹配。

      The keys should correspond to the window properties you want to set, and the value types have to match.

      这篇关于如何在使用Caliburn.Micro设置的应用程序中设置“窗口/应用程序”图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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