我在wpf和mvvm应用程序中使用组样式创建了一个数据网格。
简而言之: 不幸的是,我对每一行(项目)都遇到了以下输出错误:
PS C:\Windows\System32\WindowsPowerShell\v1.0> $web = [system.net.webrequest]::Create($Uri)
PS C:\Windows\System32\WindowsPowerShell\v1.0> $web
AllowAutoRedirect : True
AllowWriteStreamBuffering : True
AllowReadStreamBuffering : False
HaveResponse : False
KeepAlive : True
Pipelined : True
PreAuthenticate : False
UnsafeAuthenticatedConnectionSharing : False
SendChunked : False
AutomaticDecompression : None
MaximumResponseHeadersLength : 64
ClientCertificates : {}
CookieContainer :
SupportsCookieContainer : True
RequestUri : https://xy.domain.com/OAuth/token?grant_type=client_credentials&client_id=yyy&client_secret=zzz&scope=xy
ContentLength : -1
Timeout : 100000
ReadWriteTimeout : 300000
ContinueTimeout : 350
Address : https://xy.domain.com/OAuth/token?grant_type=client_credentials&client_id=yyy&client_secret=zzz&scope=xy
ContinueDelegate :
ServicePoint : System.Net.ServicePoint
Host : xy.domain.com
MaximumAutomaticRedirections : 50
Method : GET
Credentials :
UseDefaultCredentials : False
ConnectionGroupName :
Headers : {}
Proxy : System.Net.WebRequest+WebProxyWrapper
ProtocolVersion : 1.1
ContentType :
MediaType :
TransferEncoding :
Connection :
Accept :
Referer :
UserAgent :
Expect :
IfModifiedSince : 01.01.0001 00:00:00
Date : 01.01.0001 00:00:00
ServerCertificateValidationCallback :
CreatorInstance : System.Net.WebRequest+DesignerWebRequestCreate
CachePolicy : Level:BypassCache
AuthenticationLevel : MutualAuthRequested
ImpersonationLevel : Delegation
我问google这个问题,并在2015年的一篇文章中读到.net框架中可能存在错误-如果是这样,则似乎问题尚未解决。因此,我在项目中将.net框架从4.5.1更新为4.6.1(和4.7),但这并没有解决我的问题。现在我正在使用4.6.1。我不确定如何解决此问题-我尝试了几种找到的解决方案。
代码如下:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1''. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPresenter' (Name=''); target property is 'SelectiveScrollingOrientation' (type 'SelectiveScrollingOrientation')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1''. BindingExpression:Path=HeadersVisibility; DataItem=null; target element is 'DataGridRowHeader' (Name=''); target property is 'Visibility' (type 'Visibility')
非常感谢您的帮助!