Benutzer:MovGP0/WPF/Navigation
< Benutzer:MovGP0 | WPF
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
WPF Navigation[Bearbeiten | Quelltext bearbeiten]Setting up a Shell[1][Bearbeiten | Quelltext bearbeiten]
public sealed partial class App
{
protected override void OnStartup(StartupEventArgs e)
{
var resolver = ResolverFactory.Get();
var logger = resolver.Resolve<ILogger>();
RegisterGlobalExceptionHandling(logger);
var shell = resolver.Resolve<Sample.Shell>();
shell.Show();
}
private static void RegisterGlobalExceptionHandling(ILogger log)
{
AppDomain.CurrentDomain.UnhandledException +=
(sender, args) => CurrentDomainOnUnhandledException(args, log);
}
private static void CurrentDomainOnUnhandledException(
UnhandledExceptionEventArgs args, ILogger log)
{
var exception = args.ExceptionObject as Exception;
var terminatingMessage = args.IsTerminating
? " The application is terminating." : string.Empty;
var exceptionMessage = exception?.Message ?? "An unmanaged exception occured.";
var message = string.Concat(exceptionMessage, terminatingMessage);
log.Error(exception, message);
}
}
<Window x:Class="Sample.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
</Window>
namespace Sample
{
[TemplatePart(Name="PART_MainFrame", Type=typeof(Frame))]
public partial sealed class Shell
{
public Shell()
{
InitializeComponent();
}
public override void OnApplyTemplate()
{
MainFrame = Template.FindName("PART_MainFrame") as Frame;
}
}
}
<ResourceDictionary>
<Style x:Key="..." x:TargetType="Sample.Shell">
<Setter Property="Template">
<Setter.Value>
<DockPanel>
<Frame x:Name="PART_MainFrame" />
</DockPanel>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Quellen[Bearbeiten | Quelltext bearbeiten] |