Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3986092
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:58:12+00:00 2026-05-20T05:58:12+00:00

I’m totally confused after trying to solve my problem for several hours for myself,

  • 0

I’m totally confused after trying to solve my problem for several hours for myself, but there are just too many question marks. Maybe you can help me 🙂

I want to have a Pivot and binding Elements to is, so I wrote a PivotViewModel class that contains an ObservableCollection (CategoryPageList):

public class PivotViewModel
{
    public class CategoryPageList : ObservableCollection<CategoryPage>
    {}

    private CategoryPageList categoryPages;

    public PivotViewModel()
    {
        categoryPages = new CategoryPageList();
    }

    public CategoryPageList CategoryPages
    {
        get { return categoryPages; }
    }
}

The CategoryPageList is of the type CategoryPage, a class that contains the data I want to bind to, the “CategoryName”:

public class CategoryPage : INotifyPropertyChanged
{
    private string categoryName;

    public CategoryPage(string categoryName)
    {
        CategoryName = categoryName;
    }

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }

    public string CategoryName
    {
        get { return categoryName; }
        set
        {
            if (categoryName != value)
            {
                categoryName = value;
                NotifyPropertyChanged("CategoryName");
            }
        }
    }
}

When my Application is loaded, I want to see a PivotItem for each CategoryPage with the “CategoryName”-Property as header of this PivotItem.
With Expression Blend I created the following XAML-code, but it does not work, the Pivot remains empty:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.DataContext>
        <RssReader_ViewModel:PivotViewModel/>
    </Grid.DataContext>
    <controls:Pivot Title="pivot" ItemsSource="{Binding CategoryPages}">
        <controls:Pivot.Resources>
            <DataTemplate x:Key="CategoryPivotItemHeaderTemplate">
                <TextBlock TextWrapping="Wrap" Text="{Binding CategoryPages[0].CategoryName}"/>
            </DataTemplate>
            <DataTemplate x:Key="CategoryPivotItemTemplate">
                <Grid>
                    <ListBox/>
                </Grid>
            </DataTemplate>
        </controls:Pivot.Resources>
        <controls:Pivot.ItemTemplate>
            <StaticResource ResourceKey="CategoryPivotItemTemplate"/>
        </controls:Pivot.ItemTemplate>
        <controls:Pivot.HeaderTemplate>
            <StaticResource ResourceKey="CategoryPivotItemHeaderTemplate"/>
        </controls:Pivot.HeaderTemplate>
        <controls:Pivot.DataContext>
            <RssReader_ViewModel:PivotViewModel/>
        </controls:Pivot.DataContext>
    </controls:Pivot>
</Grid>

The DataContext is bound in code in the constructor of the Page:

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();

        LayoutRoot.DataContext = App.PivotViewModel;
    }
}

I’m a total beginner and do not have much idea, but the only thing I can say is, that the in XAML the Text="{Binding CategoryPages[0].CategoryName}" looks strange to me.

Does anybody see a bug? Would be really great!
Best regards!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:58:13+00:00Added an answer on May 20, 2026 at 5:58 am

    Try to insert an empty/dummy DataContext="{Binding}" to the Pivot tag.

    Remove CategoryPages[0] since you dont have access to CategoryPages collection here..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.