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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:59:07+00:00 2026-06-17T23:59:07+00:00

I have a listbox populated with 3 items from an SQLCE database using Linq.

  • 0

I have a listbox populated with 3 items from an SQLCE database using Linq.
For some reason when I select the item located at index 1, it highlights in the listbox but does not fire the selection change. If I select any other item (index 0 or 2) then the selection fires fine.

Any ideas?

I have checked the item in the database and I can’t see anything wrong with it.

EDIT: Requested Code

Xaml

  <ListBox x:Name="lbxPlans" Grid.Row="5" Grid.ColumnSpan="2" Margin="12" ItemsSource="{Binding}" ItemTemplate="{DynamicResource PlanTemplate}" SelectionChanged="lbxPlans_SelectionChanged">

  <DataTemplate x:Key="PlanTemplate">
        <Grid Margin="0,3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="Run No." VerticalAlignment="Top"/>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="{Binding RunNumber}" VerticalAlignment="Top" Grid.Column="1" Margin="6,0"/>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="Week Day:" VerticalAlignment="Top" Grid.Column="2"/>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="{Binding DayOfWeek}" VerticalAlignment="Top" Grid.Column="3" Margin="6,0"/>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="Week Number:" VerticalAlignment="Top" Grid.Column="4"/>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="{Binding WeekNumber}" VerticalAlignment="Top" Grid.Column="5" Margin="6,0"/>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="Desc:" VerticalAlignment="Top" Grid.Column="6"/>
            <TextBlock HorizontalAlignment="Left" Height="Auto" TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Top" Grid.Column="7" Margin="6,0"/>
        </Grid>
    </DataTemplate>

And

    private void GetProgrammes()
    {
        var pro = from p in Globals.Instance.Database.Programme
                  select p;

        lbxPlans.DataContext = null;
        lbxPlans.DataContext = pro;
    }

private void lbxPlans_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
    {
        // TODO: Add event handler implementation here.

        if (lbxPlans.SelectedIndex != 1)
        {
            MessageBox.Show("Selection Changed!");
        }
    }

EDIT 2: As Requested rather than creating pro from database items and assigning it to the Listbox DataContext I created them manually to eliminate database issues and still the problem is present. I then just ran an experiment by creating a List<string> with 3 values and assigned that to the listbox. The issue is still there! so is this now an issue with the Listbox itself?

  • 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-06-17T23:59:08+00:00Added an answer on June 17, 2026 at 11:59 pm

    lbxPlans.SelectedIndex != 1

    You did not trace this in the debugger?

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

Sidebar

Related Questions

I have some items populated in the listbox from the database in my asp.net
What do I have? I have a ListBox populated with items from an XML
I have a ListBox that gets populated with items read from a JSON response.
I have a listbox being populated from textbox entry. { textBox2.Text.Replace(\r\n, \r); listBox1.Items.Add(textBox2.Text); }
I have a listbox which populated from using a datatable. I have a Add
I have a ListBox defined in my app that I've populated with some static
I have a ListBox populated with data coming from XML. Fine so far, the
I have a listbox being populated from a combo box. What i need to
I have a listbox being populated from a SQLDATA pull, and it pulls down
I have a listbox that is populated with a list of List items. The

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.