1 Replies - 6597 Views - Last Post: 24 January 2013 - 11:27 AM

#1 MVasquez  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 22-January 13

Databinding issue with Async Sharepoint and Dictionary

Posted 22 January 2013 - 09:26 AM

I have to update textboxes text with data that is returned from Sharepoint. The data is shared across many viewmodels so I store it into a static dictionary. The problem occurs when the thread accessing sharepoint returns, the properties are not notified of change/ changed.

public SpModel 
{
	Static dictionary<string,string> exposedDictOfValues;
	List resultsFromSharepointXml
	
	GetSharepointXmlAsync{
		...
		resultsFromSharepointXml = _list.getItems(query);
		executeQueryAsync(success,fail);
		...
	}
	
	success()
	{
		exposedDictOfValues = Convert(resultsFromSharepointXml);
	}
	
	fail(){}
}

public ViewModel : INotifyPropertyChanged
{
	public string MyProp
	{
		get
		{
			return SpModel.exposedDictOfValues["myProp"]
		}
		set
		{
			if(SpModel.exposedDictOfValues["myProp"] != value) 
			{
				SpModel.exposedDictOfValues["myProp"] = value;
				NotifyPropChange("MyProp");
			}
			
		}
	}
}

public View
{
	view(){
		DataContext = ViewModel;
	}
}

view.xaml
<textbox Text={Binding MyProp,Mode=TwoWay} />



Is This A Good Question/Topic? 0
  • +

Replies To: Databinding issue with Async Sharepoint and Dictionary

#2 MVasquez  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 22-January 13

Re: Databinding issue with Async Sharepoint and Dictionary

Posted 24 January 2013 - 11:27 AM

Figured it out. Passed down the UI Dispatcher and executed the method using it and the viewmodel as a singleton.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1