次の例のコマンドが実行されないのはなぜですか?
AppBar と Button を含む名前付きの Page があります。
<Page
x:Class="App13.MainPage"
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"
mc:Ignorable="d"
x:Name="myPage"
>
<Page.BottomAppBar>
<AppBar>
<Button Content="OK" Command="{Binding OkCommand, ElementName=myPage}" />
</AppBar>
</Page.BottomAppBar>
</Page>
コマンド「OkCommand」は、コード ビハインドで次のように定義されます (MVVM ライト フレームワークを使用)。
public RelayCommand OkCommand
{
get
{
return m_OkCommand
?? (m_OkCommand = new RelayCommand(
async () =>
{
await new MessageDialog("OkCommand").ShowAsync();
}));
}
}
出力ウィンドウには、これが機能しない理由を示すバインディングエラーやその他のヒントはありません。(余談: ボタンが AppBar の外側に配置されている場合、すべて正常に動作します)
ここで何が間違っているのか誰にも分かりますか?