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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:36:41+00:00 2026-05-30T04:36:41+00:00

I am developing a Silverlight application which has a list <ListBox x:Name=_list_collection SelectionChanged=SelectionChanged ScrollViewer.VerticalScrollBarVisibility=Auto

  • 0

I am developing a Silverlight application which has a list

<ListBox x:Name="_list_collection"
    SelectionChanged="SelectionChanged"
    ScrollViewer.VerticalScrollBarVisibility="Auto"
    SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
    ItemsSource="{Binding Collection, Mode=TwoWay}"
    ItemTemplate="{StaticResource ScheduleListItemDataTemplate}"
    ItemContainerStyle="{StaticResource ScheduleListItemContainerDataTemplate}" Margin="10" />

The itemsource is bound to this

 public ObservableCollection<ScheduleDto> Collection
 {
     get { return _collection; }
     set
     {
         _collection = value;
         OnPropertyChanged("Collection");
     }
 }

And the selecteditem is bound to

public ScheduleDto SelectedItem
{
    get { return _selectedItem; }
    set
    {
        _selectedItem = value;
        OnPropertyChanged("SelectedItem");
    }
}

The item is being selected because I can see some details about it populate in a separate view. My only problem is that this item is not highlighted (blue background). I have tried it by adding a selectiong changed event handler which looks like this

private void SelectionChanged(object sender, SelectionChangedEventArgs e)
{
   ListBoxItem selectedItem = (ListBoxItem)_list_collection.ItemContainerGenerator.ContainerFromIndex(_list_collection.SelectedIndex);

    VisualStateManager.GoToState(selectedItem, "Selected", true); 
}

But no luck… Any advice?

Edit:

This is the ItemTemplate

<DataTemplate x:Key="ScheduleListItemDataTemplate">
    <Grid VerticalAlignment="Stretch"
          d:DesignHeight="100">
        <Grid.Resources>
            <Converters1:ScheduleStatusConverter x:Key="ScheduleStatusConverter"/>
            <Converters1:DateToStringConverter x:Key="DateToStringConverter"/>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250" />
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.ColumnSpan="3"
                    HorizontalAlignment="Stretch"
                   Text="{Binding Name}"         
                    Foreground="{Binding Converter={StaticResource ScheduleStatusConverter}}"
                   FontFamily="{StaticResource LabelTextStyle}"
                   FontSize="19" TextTrimming="WordEllipsis" VerticalAlignment="Center"/>
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition  />
                <RowDefinition />
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=[lblCreatedBy], Source={StaticResource Translations}}" VerticalAlignment="Center"/>
                <TextBlock Text=":" Margin="2,0,2,0" VerticalAlignment="Center"/>
                <TextBlock TextWrapping="Wrap"
                   Text="{Binding CreatedBy}"
                   FontFamily="{StaticResource LabelTextStyle}"
                   FontSize="16"
                   VerticalAlignment="Center"
                   Grid.Column="2"
                   Margin="0"
                   Grid.Row="1"
                   HorizontalAlignment="Right">
                    <TextBlock.Foreground>
                        <SolidColorBrush Color="{StaticResource FactualTextStyle}" />
                    </TextBlock.Foreground>
                </TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Row="1">
                <TextBlock Text="{Binding Path=[lblCoachingViewGridCreatedDate], Source={StaticResource Translations}}" VerticalAlignment="Center"/>
                <TextBlock Text=":" Margin="2,0,2,0" VerticalAlignment="Center"/>
                <TextBlock TextWrapping="Wrap"
                   Text="{Binding CreatedAt,Converter={StaticResource DateToStringConverter}}"
                   FontSize="16"
                   VerticalAlignment="Center"

                   HorizontalAlignment="Right"/>
            </StackPanel>
        </Grid>
        <Grid Grid.Column="2"
                   Margin="0"
                   Grid.Row="1" Visibility="{Binding}">
            <Grid.RowDefinitions>
                <RowDefinition  />
                <RowDefinition />
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=[lblUpdatedBy], Source={StaticResource Translations}}" VerticalAlignment="Center"/>
                <TextBlock Text=":" Margin="2,0,2,0" VerticalAlignment="Center"/>
                <TextBlock TextWrapping="Wrap"
                   Text="{Binding UpdatedBy}"
                   FontFamily="{StaticResource LabelTextStyle}"
                   FontSize="16"
                   VerticalAlignment="Center"
                   Grid.Column="2"
                   Margin="0"
                   Grid.Row="1"
                   HorizontalAlignment="Right">
                    <TextBlock.Foreground>
                        <SolidColorBrush Color="{StaticResource FactualTextStyle}" />
                    </TextBlock.Foreground>
                </TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Row="1">
                <TextBlock Text="{Binding Path=[lblUpdatedDate], Source={StaticResource Translations}}" VerticalAlignment="Center"/>
                <TextBlock Text=":" Margin="2,0,2,0" VerticalAlignment="Center"/>
                <TextBlock TextWrapping="Wrap"
                   Text="{Binding UpdatedAt,Converter={StaticResource DateToStringConverter}}"
                   FontSize="16"
                   VerticalAlignment="Center"

                   HorizontalAlignment="Right"/>
            </StackPanel>
        </Grid>
    </Grid>
</DataTemplate>

Even if I remove the style template the first item isn’t selected :/

  • 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-30T04:36:42+00:00Added an answer on May 30, 2026 at 4:36 am

    I found the answer… Thanks to @Haris Hasan

    There is a Visual stete called SelectedUnfocused. Just copied the properties from Selected and everything works fine

    <VisualState x:Name="SelectedUnfocused">
       <Storyboard>
          <DoubleAnimation Duration="0"
              To=".75"
              Storyboard.TargetProperty="Opacity"
              Storyboard.TargetName="fillColor2" />
          <ColorAnimation Duration="0"
              To="#FF8DC5F9"
              Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
              Storyboard.TargetName="fillColor2"
              d:IsOptimized="True" />
          <ColorAnimation Duration="0"
              To="#FFBCC0C0"
              Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
              Storyboard.TargetName="fillColor"
              d:IsOptimized="True" />
           <DoubleAnimation Duration="0"
              To="1"
              Storyboard.TargetProperty="(Rectangle.RadiusX)"
              Storyboard.TargetName="fillColor2"
              d:IsOptimized="True" />
        </Storyboard>
    </VisualState>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a Silverlight 3 Application which I want to connect to a webservice
I'm developing a Silverlight application that displays items in a listbox control and I've
I'm developing a Silverlight Business Application, using a RIA service, which is returning POCO
What is the correct pattern or method for developing a Silverlight application (which is
I am developing silverlight application. I have a listbox in my application. I am
I'm developing a Silverlight application, and want to set the ItemsSource of a ListBox
I'me currently developing a silverlight application. In this application, I've an exception handler which
We're developing a ASP.Net Web Application project that has a Silverlight 2.0 component. We've
I am developing a Silverlight4 Application which has elevated permissions and is running out
I am developing a silverlight 4.0 application which communicates with a WCF service. 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.