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 6675125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:48:55+00:00 2026-05-26T03:48:55+00:00

I have a ListPicker in my Windows Phone 7 app where both the ItemsSource

  • 0

I have a ListPicker in my Windows Phone 7 app where both the ItemsSource and SelectedIndex properties are bound to my ViewModel. SelectedIndex is using Two Way binding. The items and the SelectedIndex are correctly populated on application startup. However, when I modify the SelectedIndex property in my ViewModel the ListPicker’s TextBox goes blank, as if there was no selected item. If I go to full mode and check which is the selected item from the list, the correct item is being selected.

Here is the ListPicker xaml code:

<toolkit:ListPicker Name="TheListPicker" ItemsSource="{Binding TheItems}" CacheMode="BitmapCache" FullModeHeader="{Binding Path=Resources.TheHeader, Source={StaticResource LocalizedStrings }}" SelectedIndex="{Binding TheCurrentIndex, Mode=TwoWay}" IsEnabled="{Binding IsViewEnabled}" TabIndex="0" >
    <toolkit:ListPicker.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <TextBlock Text="{Binding Name}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />
            </StackPanel>
        </DataTemplate>
    </toolkit:ListPicker.ItemTemplate>
    <toolkit:ListPicker.FullModeItemTemplate>
        <DataTemplate>
            <StackPanel x:Name="item" Orientation="Horizontal" Margin="5, 24, 0, 24">
                <TextBlock Margin="15, 0, 0, 0" Text="{Binding Name}" FontSize="40" TextWrapping="Wrap" />
            </StackPanel>
        </DataTemplate>
    </toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>

This is a simplified version of my ViewModel:

[DataMember]
public ObservableCollection<ItemEntity> TheItems
{
    get
    {
        if (this.theItems == null)
        {
            this.theItems = new ObservableCollection<ItemEntity>();
        }

        return this.theItems;
    }
    set
    {
        this.theItems = value;
    }
}

[DataMember]
public int TheCurrentIndex
{
    get 
    {
        return this.theCurrentIndex;
    }
    set
    {
        if (value != this.theCurrentIndex)
        {
            this.theCurrentIndex = value;
            NotifyPropertyChanged("TheCurrentIndex");
            NotifyPropertyChanged("IsSomeOtherPropertyEnabled");
        }
    }
}

And here is the relevant code from MainPage.xaml.cs (App_ViewModelChanged is an event handler invoked when some async stuff performed on application startup finishes):

private void App_ViewModelChanged(object sender, ViewModelChangedEventArgs e)
{    
    BindToViewModel();
}

private void BindToViewModel()
{
    this.DataContext = this.ViewModel;
    this.ViewModel.IsViewEnabled = true;
}

private void SomeAsyncMethodCompleted(object sender, DetectCompletedEventArgs e)
{
    if (e.Error == null)
    {
        this.ViewModel.TheCurrentIndex = e.Result;
    }
}

This issue is not happening all the time. Happens like 50% of the time. It seems to happen only once in the application lifetime and then never happens again. Also, the issue started appearing when I switched from the Feb 2011 release of the Silverlight Control Toolkit to the Aug 2011 release. Never had this issue before.

Is this a known issue?

  • 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-26T03:48:55+00:00Added an answer on May 26, 2026 at 3:48 am

    Ok, so the reason for this strange behavior was a small change in the ListPickerItem style in Aug 2011 Silverlight Control Toolkit.

    This is how it looks in Aug 2011 release:

    <Style TargetType="controls:ListPickerItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="8 10"/>
        <Setter Property="Template">
            <!-- More Stuff Here -->
        </Setter>
    </Style>
    

    And this is how it looked in Feb 2011 release:

    <Style TargetType="controls:ListPickerItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="8 6"/>
        <Setter Property="Template">
            <!-- More Stuff Here -->
        </Setter>
    </Style>
    

    See the difference? They changed the ListPickerItem Padding to 8 10 in the new release and somehow that was causing the issue. Reverting to 8 6 fixes it. Don’t ask me why.

    So in my project I didn’t actually modified the control toolkit Generic.xaml file, but just modified the specific ListPicker resources to specify a new padding for the ListPickerItem style, like this:

    <toolkit:ListPicker Name="TheListPicker" ItemsSource="{Binding TheItems}" CacheMode="BitmapCache" FullModeHeader="{Binding Path=Resources.TheHeader, Source={StaticResource LocalizedStrings }}" SelectedIndex="{Binding TheCurrentIndex, Mode=TwoWay}" IsEnabled="{Binding IsViewEnabled}" TabIndex="0" >           
        <toolkit:ListPicker.Resources>
            <Style TargetType="toolkit:ListPickerItem">
                <Setter Property="Padding" Value="8 6"/>
            </Style>
        </toolkit:ListPicker.Resources>
        <toolkit:ListPicker.ItemTemplate>           
            <DataTemplate>           
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">           
                    <TextBlock Text="{Binding Name}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />           
                </StackPanel>           
            </DataTemplate>           
        </toolkit:ListPicker.ItemTemplate>           
        <toolkit:ListPicker.FullModeItemTemplate>           
            <DataTemplate>           
                <StackPanel x:Name="item" Orientation="Horizontal" Margin="5, 24, 0, 24">           
                    <TextBlock Margin="15, 0, 0, 0" Text="{Binding Name}" FontSize="40" TextWrapping="Wrap" />           
                </StackPanel>           
            </DataTemplate>           
        </toolkit:ListPicker.FullModeItemTemplate>           
    </toolkit:ListPicker>
    

    Such a small change!

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

Sidebar

Related Questions

I am having a problem using two way binding with a listpicker. I am
I am having a problem using two way binding with a listpicker. I am
I have two silverlight listpicker controls in my windows phone 7. Here is my
I am having an issue with two-way binding the SelectedItem of the ListPicker In
I have the following listpicker in my XAML; <toolkit:ListPicker Name=CategoryPicker ItemsSource={Binding Category} CacheMode=BitmapCache FullModeHeader={Binding
I am using the ListPicker from the Windows Phone Toolkit. It is setup very
I have a page in a Windows Phone 7 app where the user can
We have a listpicker control in Windows Phone 7 - That comes in fro0m
I am trying to use the listpicker control in windows phone 7. Such that
I am using the ListPicker from the toolkit. I have managed to apply a

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.