まあ、MahApps.Metro と Caliburn.Micro を一緒に使用しようとしていますが、いくつかの問題が発生しています
これが私のブートストラップです
public sealed class TestBootstrapper : Bootstrapper<ShellViewModel>
{
private CompositionContainer container;
protected override void Configure()
{
container = new CompositionContainer(new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()));
CompositionBatch batch = new CompositionBatch();
batch.AddExportedValue<IWindowManager>(new AppWindowManager());
batch.AddExportedValue<IEventAggregator>(new EventAggregator());
batch.AddExportedValue(container);
container.Compose(batch);
}
protected override object GetInstance(Type serviceType, string key)
{
string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;
var exports = container.GetExportedValues<object>(contract);
if (exports.Count() > 0)
{
return exports.First();
}
return base.GetInstance(serviceType, key);
}
}
そして、ここに私のAppWindowManagerがあります
public sealed class AppWindowManager : WindowManager
{
static readonly ResourceDictionary[] resources;
static AppWindowManager()
{
resources = new ResourceDictionary[]
{
new ResourceDictionary
{ Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml", UriKind.RelativeOrAbsolute) },
new ResourceDictionary
{ Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml", UriKind.RelativeOrAbsolute) },
new ResourceDictionary
{ Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml", UriKind.RelativeOrAbsolute) },
new ResourceDictionary
{ Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml", UriKind.RelativeOrAbsolute) },
new ResourceDictionary
{ Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml", UriKind.RelativeOrAbsolute) },
new ResourceDictionary
{ Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml", UriKind.RelativeOrAbsolute) }
};
}
protected override Window EnsureWindow(object model, object view, bool isDialog)
{
MetroWindow window = view as MetroWindow;
if (window == null)
{
window = new MetroWindow()
{
Content = view,
SizeToContent = SizeToContent.WidthAndHeight
};
window.MinHeight = 150;
window.MinWidth = 500;
foreach (ResourceDictionary resourceDictionary in resources)
{
window.Resources.MergedDictionaries.Add(resourceDictionary);
}
window.SetValue(View.IsGeneratedProperty, true);
Window owner = this.InferOwnerOf(window);
if (owner != null)
{
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
window.Owner = owner;
}
else
{
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
}
else
{
Window owner2 = this.InferOwnerOf(window);
if (owner2 != null && isDialog)
{
window.Owner = owner2;
}
}
return window;
}
}
これは多少機能しますが、サイズを変更するまでウィンドウの周りに黒い境界線が表示されます 下の画像を参照してください
黒い境界線があるのはなぜですか?どうすればそれを取り除くことができますか (手動でウィンドウのサイズを変更すると、境界線が消えます)。