これらの 3 種類の WPF アプリケーションがあります...
- WindowMain
- UserControlZack
- ウィンドウモーダル
UserControlZack1 は私の WindowMain に座っています...
<Window x:Class="WindowMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ProjectName"
...
Name="WindowMain">
<Grid>
...
<local:UserControlZack x:Name="UserControlZack1" ... />
...
</Grid>
</Window>
UserControlZack1 は WindowModal ダイアログ ボックスを表示します...
部分パブリック クラス UserControlZack ... プライベート サブ SomeButton_Click(...) 'ダイアログ ボックスをインスタンス化し、モーダルで開く... 薄暗いボックス As WindowModal = New WindowModal() box.Owner = ????? box.ShowDialog() 'ダイアログボックスが受け入れられた場合、ユーザーが入力したデータを処理します... If (box.DialogResult.GetValueOrDefault = True) その後 _SomeVar = box.SomeVar ... 終了条件 サブ終了 クラス終了
box.Owner を WindowMain の実行中のインスタンスである正しい Window に設定するにはどうすればよいですか?
box.Owner = Me.Owner
「'Owner' は 'ProjectName.UserControlZack' のメンバーではないため、使用できません。」
box.Owner = Me.Parent
ウィンドウではなくグリッドを返すため、使用できません。
box.Owner = WindowMain
「'WindowMain' は型であり、式として使用できない」ため、使用できません。