フライアウトがあります (以下の関連部分):
<Flyout x:Key="flyoutAverage" FlyoutPresenterStyle="{StaticResource flyoutPresenter}" Closed="Flyout_Closed">
<Grid>
<TextBox Grid.Row="1" Grid.Column="0" Text="{Binding One, Mode=TwoWay}" InputScope="Number" Margin="5,0" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Two, Mode=TwoWay}" InputScope="Number" Margin="5,0" />
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Three, Mode=TwoWay}" InputScope="Number" Margin="5,0" />
<TextBlock Grid.Row="1" Grid.Column="3" FontSize="18" VerticalAlignment="Center" Text="{Binding Average}" />
</Grid>
</Flyout>
これは、次のボタンで表示されます。
<StackPanel Orientation="Horizontal" DataContext="{Binding Neck}">
...
<Button Flyout="{StaticResource flyoutAverage}">Enter</Button>
</StackPanel>
ボタン (およびフライアウト) のデータ コンテキストは、このオブジェクトのインスタンスです。
public decimal One
{
get { return m_One; }
set { m_One = value; PropChanged("First"); PropChanged("Average"); }
}
public decimal Two
{
get { return m_Two; }
set { m_Two = value; PropChanged("Second"); PropChanged("Average"); }
}
public decimal Three
{
get { return m_Three; }
set { m_Three = value; PropChanged("Third"); PropChanged("Average"); }
}
public decimal Average
{
get
{
return (One + Two + Three) / 3;
}
}
意図した動作は、ユーザーがボタンをクリックすると、次のように表示されることです。
ユーザーが各テキスト ボックスに値を入力すると、「平均」テキスト ブロックが平均値で自動的に更新されます。
テキストボックスには正しい値が入力されますが、オブジェクトにプッシュバックされることはありません。フライアウトを閉じて再度開くと、値が保持されます。TwoWay として明確に設定されている場合、Binding モードが OneWay であるかのようです。
何か案は?それとも、私はそれを間違っていますか?