ここでは、「ChildView」という名前の UserControl があり、「listView」という名前の 1 つの ListView コントロールがあります。この listView の「SelectedItems」プロパティをメイン ウィンドウからコマンド パラメータとしてバインドしようとしていますが、実行されません。関数の実行パラメーターは常に null です。
以下はコードスニペットです。
ChildView
<UserControl x:Class="MyProj.Views.ChildView"
…………..
<ListView x:Name="listView" …………..
MainView
…………..
<views:ChildView x:Name="childView" />
…………..
<Button Command="{Binding ElementName=childView, Path=DataContext.CmdCopyLines}" CommandParameter="{Binding ElementName=childView, Path=DataContext.listView.SelectedItems}" Label="Copy" />
…………..
しかし、それは子供の視点から直接起こっています
ChildView
<UserControl x:Class="MyProj.Views.ChildView"
…………..
<ListView x:Name="listView"
…………..
<Button Command="{Binding CmdCopyLines}" CommandParameter="{Binding ElementName=listView, Path=SelectedItems}" Label="Copy" />
…………..
どんな助けでも大歓迎です