Ratatat Richie
Ratatat Richie

Reputation: 131

Windows Store Universal 8.1 App How to Bind to data in Shared area

I'm Porting my working Phone8 app to a Universal one (Store and Phone 8.1)

Class NewsList extends ObservableCollection. I bind to it in a Listview in Xaml with ItemsSource="NewsItems" using markup like this:

xmlns:news="clr-namespace:BowlsGroup.Data.News"

<phone:PhoneApplicationPage.Resources>
    <ResourceDictionary>
        <news:NewsList x:Key="NewsItems"/>
    </ResourceDictionary>
</phone:PhoneApplicationPage.Resources>

This worked for Phone8.

I created a new Universal app and placed class NewsList in the Shared area.

With the above dictionary resources now in a Page.Resources block, the above code no longer works. I get: "The name NewsList does not exist in the namespace BowlsGroup.Data.News".

Which is not the case. I tried doing the markup in App.xaml but same problem.

Question is: How to bind to data located in the Shared project area?

The NewsList declartion part:

namespace BowlsGroup.Data.News
{
    public class NewsList : ObservableCollection<NewsItem>, INotifyPropertyChanged
    {
    }
}

Upvotes: 1

Views: 546

Answers (2)

Ratatat Richie
Ratatat Richie

Reputation: 131

Thanks Jogy for your help. Months ago I had a similar problem which was cured when other anomalies were sorted. Sometimes I've had to close the solution and reopen it. I cant actually pinpoint what kind of errors in the c# code caused this latest problem.

When building the code, the only errors reported were of the type: "The name blah does not exist in the namespace tiddleypom". I tried so many things yesterday, including removing some Silverlight-ridden code. (I am porting a phone8 app to the universal 8.1 solution).

i think it goes like this; With the offending xmlns markup I get the one error. When I remove the markup I see other errors. On fixing these and reinstating the markup the projects build without errors.

Sorry about the vague answer, thanks again.

Upvotes: 0

Jogy
Jogy

Reputation: 2475

Change

xmlns:news="clr-namespace:BowlsGroup.Data.News" 

to

xmlns:news="using:BowlsGroup.Data.News"

Check this blog post for the difference in referring to namespaces in WinRT vs Silverlight: http://www.thomasclaudiushuber.com/blog/2012/08/18/windows-store-apps-winrt-xaml-vs-silverlight-xaml/

Upvotes: 1

Related Questions