0
类
的WPF数据绑定的问题我已经在服务器一个WCF [MessageContract]
[MessageContract]
public class RemoteFileInfo : IDisposable, INotifyPropertyChanged
{
[MessageHeader(MustUnderstand = true)]
public string _FileName;
[MessageHeader(MustUnderstand = true)]
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
[MessageBodyMember(Order = 1)]
public System.IO.Stream _FileByteStream;
[MessageHeader(MustUnderstand = true)]
public System.IO.Stream FileByteStream
{
get { return _FileByteStream; }
set { _FileByteStream = value; }
}
public void Dispose()
{
// close stream when the contract instance is disposed.
// this ensures that stream is closed when file download
// is complete, since download procedure is handled by the client
// and the stream must be closed on server.
if (_FileByteStream!=null)
{
_FileByteStream.Close();
_FileByteStream = null;
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
我通过WCF我的服务器进行通信的一类。这个类应该是[MessageContract],因为流式传输 - (我的所有其他类无论如何都使用[DataContract])。
我的问题是,经过我产生在客户端与SvcUtil工具类我失去了inotify的... ...界面我得到这样的:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName="RemoteFileInfo", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class RemoteFileInfo
{
[System.ServiceModel.MessageHeaderAttribute(Namespace="http://tempuri.org/")]
public System.IO.Stream FileByteStream;
[System.ServiceModel.MessageHeaderAttribute(Namespace="http://tempuri.org/")]
public string FileName;
[System.ServiceModel.MessageHeaderAttribute(Namespace="http://tempuri.org/")]
public string _FileName;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
public System.IO.Stream _FileByteStream;
public RemoteFileInfo()
{
}
public RemoteFileInfo(
System.IO.Stream FileByteStream,
string FileName,
string _FileName,
System.IO.Stream _FileByteStream)
{
this.FileByteStream = FileByteStream;
this.FileName = FileName;
this._FileName = _FileName;
this._FileByteStream = _FileByteStream;
}
}
没有INotifyPropertyChanged的数据绑定不工作,我知道但我可以在客户端添加它,因为我这样做:
public partial class RemoteFileInfo : System.ComponentModel.INotifyPropertyChanged
{
#region INotifyPropertyChanged Members
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
#endregion
}
但仍然数据绑定不起作用。你有什么主意吗? 我无法使用[MessageContract]类的数据绑定?
感谢您的提前解答!
好的。感谢您的快速回答!我想,但现在我知道了:)。 但我仍然不明白为什么当我试图在本地添加接口时,我没有正确绑定 - 正如您在我的笔记的最后一部分中看到的那样。你知道吗? – Hunsoul 2009-07-21 15:03:11