2011-01-18 6 views
0

Silverlight ChildWindow가 있습니다. 링크를 클릭하면이 자식 윈도우가 열리고 내 ViewModel의 일부 데이터가 표시됩니다. 문제는 ViewModel의 데이터가 업데이트 될 때 업데이트되지 않는다는 것입니다. 팝업에서Silverlight 개체의 속성에 대한 데이터 바인딩

샘플 :

<TextBox Text="{Binding Path=AgentExceptionDetail.Action, Mode=TwoWay}" /> 

뷰 모델 :

private AgentExceptionDetail _agentExceptionDetail; 
public AgentExceptionDetail AgentExceptionDetail 
{ 
    get { return _agentExceptionDetail; } 
    set 
    { 
    if (value != _agentExceptionDetail) 
    { 
     RaisePropertyChanged("AgentExceptionDetail"); 
     _agentExceptionDetail = value; 
    } 
    } 
} 

이 AgentExceptionDetail 객체는 RIA-서비스의 호출을 통해서 채워집니다. 이 호출이 성공하고 데이터가 다시 가져옵니다. OneWay보다는 Mode = OneTime처럼 바인딩이 실제로 작동합니다. 팝업을 닫고 다시 열면 데이터가 표시되지만 팝업이 처음 열리면 AgentExceptionDetail = null이 반환되어 호출이 다시 돌아올 때 채워집니다.

바인딩이 실제로 "AgentExceptionDetail.Action"을 찾고있을 때 "AgentExceptionDetail"에 대한 속성 변경 이벤트를 발생시키는 것과 관련이 있습니까? 그렇다면이 방법이 있습니까?

+0

업데이트 할 내용이 조금 더 필요하십니까? AgentExceptionDetail 또는 해당 Action 속성 Action 속성은 어떤 모습입니까? ... 개념적으로 당신이하고있는 것은 올바르게 보인다! – ColinE

답변

2

귀하의 설명을 올바르게 이해한다면 귀하의 시나리오에서 필요한대로 작동해야합니다. 그러나 여기에 심각한 문제가 있습니다.

if (value != _agentExceptionDetail) 
    { 
     RaisePropertyChanged("AgentExceptionDetail"); 
     _agentExceptionDetail = value; 
    } 

실제로 변경하기 전에 변경 사항 알림을 보내고 있습니다. 이 오류를 수정하려면 작업 순서를 반대로하십시오.

if (value != _agentExceptionDetail) 
    { 
     _agentExceptionDetail = value; 
     RaisePropertyChanged("AgentExceptionDetail"); 
    } 
+0

나는 내 머리를 부끄럽게 여기다 ... 네 말이 맞다. 나는 무엇인가 바꾸기 전에 사건을 일으키고 있었다. 모범생 오류! 고맙습니다. 나는 너무 오랫동안 그것을 꼼짝 않고 바라보고 있었기 때문에 나는 그 명백한 것을 놓쳤다. – Fermin

관련 문제