Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Orchestral.MahApps自定义窗口_C#_Wpf_Mahapps.metro_Catel_Orchestra - Fatal编程技术网

C# Orchestral.MahApps自定义窗口

C# Orchestral.MahApps自定义窗口,c#,wpf,mahapps.metro,catel,orchestra,C#,Wpf,Mahapps.metro,Catel,Orchestra,我正在尝试使用Orchestration框架创建自定义的MahApps.Metro窗口 我已经复制了currennt ShellWindow内容(视图+代码隐藏)并创建了自己的窗口。然后在App.xaml.cs中,我使用了我的窗口而不是ShellWindow如下所示: shellService.CreateWithSplash<MyShellWindowView>() shellService.CreateWithSplash() 问题是,此窗口的样式不正确(例如,最小化/最大化

我正在尝试使用Orchestration框架创建自定义的MahApps.Metro窗口

我已经复制了currennt ShellWindow内容(视图+代码隐藏)并创建了自己的窗口。然后在
App.xaml.cs
中,我使用了我的窗口而不是
ShellWindow
如下所示:

shellService.CreateWithSplash<MyShellWindowView>()
shellService.CreateWithSplash()
问题是,此窗口的样式不正确(例如,最小化/最大化/关闭按钮)

这是我的窗口:

<orchestra:MetroDataWindow x:Class="CatelApp.Views.MyShellWindowView"
                         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         xmlns:catel="http://catel.codeplex.com"
                         xmlns:orchestra="https://github.com/orcomp/orchestra"
                         SaveWindowPosition="False" d:DesignHeight="696" d:DesignWidth="480" mc:Ignorable="d">

  <orchestra:MetroDataWindow.Resources>
    <ResourceDictionary>
      <Style TargetType="catel:TabControl" BasedOn="{StaticResource {x:Type TabControl}}" />
    </ResourceDictionary>
  </orchestra:MetroDataWindow.Resources>

  <Border x:Name="border" BorderThickness="1">
    <DockPanel LastChildFill="True" Margin="15, 5, 15, 5">

      <StatusBar x:Name="statusBar" DockPanel.Dock="Bottom">
        <orchestra:AnimatingTextBlock x:Name="statusTextBlock" HorizontalAlignment="Left" VerticalAlignment="Center">
          <orchestra:AnimatingTextBlock.ShowStoryboard>
            <Storyboard>
              <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.2"/>
            </Storyboard>
          </orchestra:AnimatingTextBlock.ShowStoryboard>
          <orchestra:AnimatingTextBlock.HideStoryboard>
            <Storyboard>
              <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.2"/>
            </Storyboard>
          </orchestra:AnimatingTextBlock.HideStoryboard>
        </orchestra:AnimatingTextBlock>
      </StatusBar>

      <ContentControl x:Name="contentControl" />
    </DockPanel>
  </Border>

</orchestra:MetroDataWindow>

和代码隐藏

namespace CatelApp.Views
{
    /// <summary>
    /// Interaction logic for MyShellWindowViewModel.xaml
    /// </summary>
    public partial class MyShellWindowView : MetroDataWindow, IShell
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        public MyShellWindowView()
        {
            var serviceLocator = ServiceLocator.Default;

            var themeService = serviceLocator.ResolveType<IThemeService>();
            ThemeHelper.EnsureApplicationThemes(GetType().Assembly, themeService.ShouldCreateStyleForwarders());

            MahAppsHelper.ApplyTheme();

            InitializeComponent();

            var accentColorBrush = ThemeHelper.GetAccentColorBrush();
            border.BorderBrush = accentColorBrush;

            var statusService = serviceLocator.ResolveType<IStatusService>();
            statusService.Initialize(statusTextBlock);

            var commandManager = serviceLocator.ResolveType<ICommandManager>();
            var flyoutService = serviceLocator.ResolveType<IFlyoutService>();
            var mahAppsService = serviceLocator.ResolveType<IMahAppsService>();

            serviceLocator.RegisterInstance<IAboutInfoService>(mahAppsService);

            var flyouts = new FlyoutsControl();
            foreach (var flyout in flyoutService.GetFlyouts())
            {
                flyouts.Items.Add(flyout);
            }

            Flyouts = flyouts;

            var windowCommands = mahAppsService.GetRightWindowCommands();

            if (mahAppsService.GetAboutInfo() != null)
            {
//              var aboutWindowCommand = WindowCommandHelper.CreateWindowCommandButton("appbar_information", "about");

//              var aboutService = serviceLocator.ResolveType<IAboutService>();
//              commandManager.RegisterAction("Help.About", aboutService.ShowAbout);
//              aboutWindowCommand.Command = commandManager.GetCommand("Help.About");

//              windowCommands.Items.Add(aboutWindowCommand);
            }

            RightWindowCommands = windowCommands;

            var mainView = mahAppsService.GetMainView();
            contentControl.Content = mainView;

            SetBinding(TitleProperty, new Binding("ViewModel.Title") {Source = mainView});
        }

        #endregion
    }
}
namespace CatelApp.Views
{
/// 
///MyShellWindowViewModel.xaml的交互逻辑
/// 
公共部分类MyShellWindowView:MetroDataWindow,IShell
{
#区域构造函数
/// 
///初始化类的新实例。
/// 
公共MyShellWindowView()
{
var serviceLocator=serviceLocator.Default;
var themeService=serviceLocator.ResolveType();
ThemeHelper.EnsureApplicationThemes(GetType().Assembly,themeService.ShouldCreateStyleForwarders());
MahAppsHelper.ApplyTheme();
初始化组件();
var accentColorBrush=ThemeHelper.GetAccentColorBrush();
border.BorderBrush=accentColorBrush;
var statusService=serviceLocator.ResolveType();
statusService.Initialize(statusTextBlock);
var commandManager=serviceLocator.ResolveType();
var flyoutService=serviceLocator.ResolveType();
var mahAppsService=serviceLocator.ResolveType();
serviceLocator.RegisterInstance(mahAppsService);
var弹出型按钮=新的弹出型按钮控制();
foreach(flyoutService.GetFlyouts()中的var弹出按钮)
{
弹出型按钮。项目。添加(弹出型按钮);
}
弹出型按钮=弹出型按钮;
var windowCommands=mahAppsService.GetRightWindowCommands();
if(mahAppsService.GetAboutInfo()!=null)
{
//var aboutWindowCommand=WindowCommandHelper.CreateWindowCommandButton(“appbar_信息”、“关于”);
//var aboutService=serviceLocator.ResolveType();
//RegisterAction(“Help.About”,aboutService.ShowAbout);
//aboutWindowCommand.Command=commandManager.GetCommand(“Help.About”);
//windowCommands.Items.Add(aboutWindowCommand);
}
RightWindowCommands=windowCommands;
var mainView=mahAppsService.GetMainView();
contentControl.Content=mainView;
设置绑定(TitleProperty,新绑定(“ViewModel.Title”){Source=mainView});
}
#端区
}
}

您是否在应用程序资源中包含MahApps主题?例如,请参见下面的代码:

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Resources/Icons.xaml" />

    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />

    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
</ResourceDictionary.MergedDictionaries>