Benutzer:MovGP0/WPF/Navigation
aus Wikipedia, der freien Enzyklopädie
< Benutzer:MovGP0 | WPF
Dies ist die aktuelle Version dieser Seite, zuletzt bearbeitet am 7. November 2016 um 16:13 Uhr durch imported>MovGP0(77247) (→WPF Navigation).
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Setting up a Shell[1]
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 |