-1

バインドしようとしているビューモデルのプロパティ:

 private TextActionValue _textActionVal;
    public TextActionValue TextActionVal
    {
        get { return _textActionVal; }
        set
        {
            _textActionVal = value; 
        }
    }

xaml:

<Grid Margin="0,15,15,15" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <GroupBox Grid.Row="1" BorderThickness="0">
        <TextBox Margin="0,5,0,5" AcceptsReturn="True" AcceptsTab="True" Text="{Binding TextActionValue.Text}" HorizontalAlignment="Stretch" MinHeight="100"></TextBox>
    </GroupBox>
</Grid>

そして最後に TextActionValue クラス:

public class TextActionValue : ISomeAction, INotifyPropertyChanged
{
    private String _text;
    public String Text
    {
        get { return _text; }
        set
        {
            _text = value;
            OnPropertyChanged("Text");
        }
    }

    #region INotifyPropertyChanged Members

    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    #endregion
}

テキスト プロパティが入力されます。踏むと確かにそこに価値がある。

基本的な文字列プロパティにバインドするだけで機能します。「TextActionValue.Text」は好きではありません。できれば避けたいリファクタリングを行わない限り、これはオプションではありません。

TextActionValue get 内にブレークポイントを配置すると、get がヒットすることはありません。したがって、これはバインディングが作成されないことを示しています。なぜ...または私がやろうとしていることは不可能ですか?

4

1 に答える 1

2

TextActionVal.Textの代わりにバインドしてみてくださいTextActionValue.Text

プロパティではなくクラスにバインドしようとしています。

また、デバッグ中に出力ウィンドウをチェックして、データ バインディング エラーを確認します。

于 2012-09-24T15:37:37.013 に答える