友人がいない - これは解決された問題です。 すべてのソリューションに本当の美しさはないが、たとえばDialog-Serviceを使用することができます。
本当に簡単に実装できるのはSingleton
で、Main-Window
の静的フィールドがあります。これで、このクラスからDialogを呼び出すことができます。
私は実際には例えばMahAppsはこのように書きますが、彼らはそれを空想方法を登録思う:ここ
<controls:MetroWindow
x:Class="SomeMetroWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
Dialog:DialogParticipation.Register="{Binding}"> <!-- watch this pls --->
<!-- ... --->
</controls:MetroWindow>
は、一般的な実装のためのexampleです。そしてここに別のarcticleこのトピックのarcticlesについて。
私が言ったように - 本当に美しいわけではありませんが、解決されました。
タイプの安全性に関するヒントをありがとうございます。本当に私は考えています。 – Rekshino