WPF与我的流绑定混乱?

时间:2014-02-20 20:59:14

标签: c# wpf data-binding stream

我使用Stream类型的属性制作了一个控件 我喂它的流有CanWrite& CanRead设置为true,这是必要的。

调试时我注意到,在我调用OnPropertyChanged之后(其名称不言自明),这些属性变为错误。

排除了一些不相关的代码,它看起来像这样:

public Stream FileStream
{
    get { return _fileStream; }
    private set
    {
        _fileStream = value;

        // Can read and write (for both _fileStream and value).
        OnPropertyChanged();
        // Can NOT read and write anymore.
    }
}

知道什么会导致这种尴尬的行为吗? 我会显示更多代码,但我还没有任何线索。


仍在诊断,这是我从OnPropertyChangedFileStream的getter之间的调用堆栈,似乎可以访问它:

'The getter in the code shown above'
[Native to Managed Transition]  
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.GetValue(object, int) Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue(int) Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue()    Unknown
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.RawValue()  Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.TransferValue(object, bool) Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.ScheduleTransfer(bool)  Unknown
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.NewValueAvailable(bool, bool, bool) Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(int, System.ComponentModel.ICollectionView, object, bool)  Unknown
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(object, string) Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(object, System.ComponentModel.PropertyChangedEventArgs) Unknown
WindowsBase.dll!System.Windows.WeakEventManager.ListenerList<System.ComponentModel.PropertyChangedEventArgs>.DeliverEvent(object, System.EventArgs, System.Type)    Unknown
WindowsBase.dll!System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(object, System.ComponentModel.PropertyChangedEventArgs) Unknown
'OnPropertyChanged'

我也认为它可能会更新更改,并且绑定会再次将其更改为不良内容,因此我已将模式设置为流的绑定上的OneWay,但这也无济于事。< / p>

0 个答案:

没有答案