변수를 보았을 때 My PropertyChanged 이벤트가 올바르게 설정되지만 코드의 어딘가에서 null로 재설정되고 어떻게되는지 파악할 방법이 없습니다. 하여 PropertyChanged에 null로 설정지고 WHERE 식별을 시도PropertyChangedEventHandler가 변경 될 때 감지
public event PropertyChangedEventHandler PropertyChanged;
//this is in the NotifyTaskCompletion class, as used from the blog
// http://msdn.microsoft.com/en-us/magazine/dn605875.aspx
private async Task WatchTaskAsync(Task task)
{
try
{
await task; //After this task, PropertyChanged gets set to a non-null method("Void OnPropertyChanged()")
}
catch
{
}
//PropertyChanged, which was set to a value after the task was run, and still not null during IdentifyCompleted getting set, is now null here
var propertyChanged = PropertyChanged;
if (propertyChanged == null)
return;
//other code
}
//My Watch variable of PropertyChanged is still good after this setter is run.
public NotifyTaskCompletion<GraphicCollection> IdentifyCompleted
{
get { return _IdentifyCompleted; }
set
{
_IdentifyCompleted = value;
// _IdentifyCompleted.PropertyChanged+= new PropertyChangedEventHandler(this, new PropertyChangedEventArgs("IdentifyCompleted"));
// NotifyPropertyChanged();
}
}
내 주요 문제는 내가 {; 얻을 세트}을 사용할 수 없다는 것입니다 : 여기
코드를 제공한다. 그래서 내 주된 질문은, 누군가 분명히 틀린 것을 보지 않는다면, 그것이 null로 설정되는 곳을 찾는 방법은 무엇입니까? 도움을 주셔서 감사합니다.private PropertyChangedEventHandler _propertyChanged;
public event PropertyChangedEventHandler PropertyChanged
{
add { _propertyChanged += value; }
remove { _propertyChanged -= value; }
}
을 그리고 여기에 문제가 다음과 같이
편집 마지막 포스터의 제안으로 당
, 내 코드를 설정합니다.
//this is in my View Model. The ViewModel CONTAINS NotifyTaskCompletion<GraphicCollection> IdentifyCompleted which in turn implements INotifyPropertyChanged and has its own PropertyChanged that is not getting set
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
//This line sets the PopertyChanged in the view model AND in the NotifyTaskCompletion class somehow, but I don't know how it is setting it properly in the NotifyTaskCompletion class in my other project where this code works, When I step through this line in my code, it doesn't trigger
//the add{} of the PropertyChanged in NotifyTaskCompletion, but it DOES in my other project...
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
그럼 이제는 어떤 줄이 작동하는지 알아볼 수는 있지만 작동하지 않는 이유는 알 수 없습니다. 다른 아이디어? 지금까지 도움을 주셔서 감사합니다.
은 WatchTaskAsync 메소드의 호출 코드를 보여줍니다. – pushpraj
http://msdn.microsoft.com/en-us/magazine/dn605875.aspx 나는 정확한 코드를 사용하고 있으며 일을 수행하는 방식을 모방하려고했습니다. 하나의 프로젝트에서 작동하지만 다른 프로젝트에서는 작동하지 않습니다. –
비동기 바인딩을 만들려고하는 것 같습니다. 이 경우 http://stackoverflow.com/questions/24731335/async-loading-images-in-wpf-value-converter/24731602#24731602가 도움을 줄 수 있는지 확인하십시오. – pushpraj