.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Animate listbox items from ItemTemplate

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :WPF
I want to have a slide-in effect for listbox items, when it's first loaded. I'm using ItemTemplate for listbox items and I coule do the slide-in effect from within the template using RenderTransform and DocubleAnimation. but as the Listbox is vertualized, it does the effect everytime new page of data is loaded in listbox. What I want is to animate the visible items in listbox only when DataContext is changed the first time, like messages list in 'Windows Live Mail' thanks in advance.  

View Complete Post

More Related Resource Links

animate effect work but the render items are messed up.


Hi all,

     I have a very unique problem, humm i think. I am using a jquery effect that animate bounce effect, i have a line in my javascript pageLoad function $("#UserBrowserInfoDIV").show('bounce'); - the effects run smoothly but what it does is mess up the bolded text in the div. I have try the items inside the div without bolding and it works fine and no render problem but when bolded the text that are bolded is quite messed up, and barely readable.

Please let me know is there anything else i can do i really would like use this effect.

P.S all the effect have the same render problem, and i am using ie8 under compatibility mode.





How to create a dynamically populated items in a listbox and use it as a navigation?

Hello, I am trying to create navigation inside a listbox menu. I load data from xml to populate a list. Each item in the list box should be a link or button. Then, I create a frame to load xaml pages in it. I tested to load pages employing button control, outside listbox with on click event and it worked well. However, I cannot make it work with list box items. I am hoping to get help from you. Any sample or ideas are highly appreciated. Below is the code:  XML: <?xml version="1.0" encoding="utf-8"?> <Pages> <page id="page01"> <name>Page 01</name> </page> <page id="page02"> <name>Page 02</name> </page> </Pages> C# to initiate a click o n listbox item and get the path to page: private void SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem); string itemName = lbi.Content.ToString(); if ( Nav_ListBox.SelectedItem.Equals("Page01" ) ) { ContentFrame.Source = new Uri("Pages/Page01.xaml", UriKind.RelativeOrAbsolute); } } XAML:  <ListBox x:Name="Nav_ListBox" Margin="0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="#FFF2F2F2" ItemTemplate="{DynamicReso

WPF, MVVM, Commands from buttons within a Listbox ItemTemplate? (code included)

I want to capture button clicks from within a list item row. Below I have tried to boil the problem down as much as I can. First, here is the xaml <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="test2.MainWindow" x:Name="Window" Title="MainWindow">  <Grid x:Name="LayoutRoot">  <ListView Margin="148,74,0,202" HorizontalAlignment="Left" ItemsSource="{Binding ListData}">   <ListView.View>    <GridView>     <GridViewColumn Header="Item" DisplayMemberBinding="{Binding ItemName}" />     <GridViewColumn Header="Options" Width="200" >      <GridViewColumn.CellTemplate>       <DataTemplate>        <StackPanel Orientation="Horizontal">         <Button Content="Reject" Height="20" Width="80" Margin="5,2" Command="{Binding Commands}" CommandParameter="RejectItem" /> 

XamlParseException thrown when setting ListBox ItemTemplate.

What could be the cause of the issue described below and why is this exception thrown? Having created a DataTemplate like this: <DataTemplate x:Key="{x:Static controls:InternalResourceKeys.ListBoxItemTemplate}" DataType="{x:Type games:GameDefinitionBase}"> </DataTemplate>   I tried to use it as an ItemTemplate in a ListBox:   <ListBox x:Name="list_definitions" HorizontalContentAlignment="Stretch" SelectionMode="Single" ItemTemplate="{StaticResource {x:Static controls:InternalResourceKeys.ListBoxItemTemplate}}"> </ListBox>   where 'InternalResourceKeys' is the following:   static class InternalResourceKeys { static readonly object _listBoxItemTemplate = new object(); public static object ListBoxItemTemplate { get { return _listBoxItemTemplate; } } }   However, the resource lookup throws an exception (pasted at the end). The reason is most possibly this: {x:Static controls:InternalResourceKeys.ListBoxItemTemplate} used as DataTemplate key. What is a bit surprising is that I have already used InternalResourceKeys class as a storage for resource keys in the same application. Thus, the concept of resource keys being retrieved by a static property seems to work. NOTE: when I change all occurences of {x:Static controls:InternalR

WPF: listbox ItemTemplate

We have a list box. Each item is a TextBlock. If the text too long, it will display as Ellipsis "..." at the end inside textblock. if the available list is too long, it will display a vertical scroll bar for the listbox. if the available list can be displayed in one page, the vertical scroll bar will not displayed. We have difine the <ListBox.ItemTemplate> <DataTemplate> <TextBlock Width="610" TextAlignment="Center" TextTrimming="CharacterEllipsis" Padding="3,0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Foreground="Black" Text="{Binding ProgramName}"/> </DataTemplate> </ListBox.ItemTemplate> The problem with this ItemTemplate, we have to define the textBlock's width in order to align the text content in the center and display the Ellipsis if text content is too long. However the real width is different with/without displaying the vertical scrool bar of listbox. So far we have to base on the vertical scroll bar displayed to decide the textblock's width. Is there someway, we can fix this problem? thx!  

Selecting Items in a databound ListBox

Hi All, I'm facing a problem while trying to programatically preselect few items in a databound ListBox. I have set the datasource of the listbox to a DataTable, with required Data and Value member columns. The selection mode of the listbox is MULTIEXTENDED. Platform: .NET  1.1 (not sure if the problem is relevant to other versions) I tried preselecting items in a different ListBox that is not bound to any datasource. I'm able to preselect items using the SetSelected method. Perfect!   How can I achieve the same for a databound ListBox? What am I missing? Any help will be very much appreciated.   Regards, Amirtha

Reverse Superscript for Listbox Items in C# windows

I want to show Reverse Super script formate for Listbox Items when i check CheckBox using c# windows forms. thanks ram

How to get values setted in custom items from a ListBox




I have a ListBox which looks like that :

Its DataTemplat is :


<DataTemplate x:Key="IndexDataTemplate">
   <StackPanel Margin="0,0,0,5">
    <TextBlock Height="Auto"

Problem when adding items to a listbox from different threads


I have an application in which different threads add items to a listbox throughout the application's execution (not at startup). But when one of the threads tries to add an item to the listbox, a System.InvanlidOperationException is thrown and the error message is: "The calling thread cannot access this object because a different thread owns it." (In my scenario the "calling thread" is one of the worker threads that add items to the listbox, and the "different thread" is the UI thread.)

So basically I just need a simple way to allow the threads to share the listbox object, or, failing that, some other workaround.

style not applied in ListBox.ItemTemplate


I have a resource dictionary with a style for Borders. The style has a TargetType but no x:Key. The dictionary also has a DataTemplate used as a ListBox.ItemTemplate. The DataTemplate has a Border in it. The Border style is not applied in the ListBox. I assumed that it would be. That is what I want.

What is the simplest way to get the Border style applied in the ListBox.ItemTemplate?


Adding Items to ListBox with animation



I have the following code:

<DataTemplate x:Key="DataTemplate1">
		<EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="textBlock">

Coloring DropDown ListBox Items


I have a situation where some dropdown listboxes contain some items, then there's a separator line, and then there are more items.  The ones above the separator line reflect the "commonly used items".  To better highlight these I was using code like this to individually color those specfic items:

         foreach (ListItem item in ddList.Items)
          if (item.Value == "-1")
            unAssigned = true;

          if (!unAssigned)
            item.Attributes.Add("style", "color:#5558ff");

This code works fine EXCEPT that once a PostBack occurs then the highlighting disappears.  The items in the dropdown listbox remain (without repopulation) but not the highlighting.

I'm curious why this is happening and whether there's a way for the highlighting to "stick" short of calling this code from the Page_Load event handler every Postback?


WPF ListBox doesn't Group items if I don't use ItemSource.


WPF ListBox doesn't Group items if I don't use ItemSource.

This code snippet works but I use



private ObservableCollection<

System.Windows.Data Error: 26 : ItemTemplate and ItemTemplateSelector are ignored for items already



I have a problem with ItemTemplates:

< ItemsControl ItemsSource = " {Binding ViewList} " >
< ItemsControl .ItemTemplate >
< DataTemplate >
< GroupBox >
< ContentControl Content = " {Binding} " />
</ GroupBox >
</ DataTemplate >

How to unselect selected items in Listbox after SelectedIndexChanged


Hello i have a listbox LbGeneratedExcelLinks  when i click inside of it on an item it download the selected item

here s my code

Protected Sub LbGeneratedExcelLinks_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbGeneratedExcelLinks.SelectedIndexChanged
        Dim RedirectUrl As String = LbGeneratedExcelLinks.SelectedValue
        LbGeneratedExcelLinks.SelectedIndex = Nothing
    End Sub

problem is if i want to click on another button or other event it keeps showing the dialog open or save file the one i put inside selectedindexChanged

 i need help to unselect after the selectedindexchanged i think it will solve my problem

Listbox hyperlink items


Hello , i want to create a dynamic listbox where items are links (each item is a hyperlink)

here 's my code

Using sw As StreamWriter = New StreamWriter(Server.MapPath("~/Output/" & weeknumber & ".xls"))
                    Dim hlk As New HyperLink
                    hlk.NavigateUrl = ("~/Output/" & weeknumber & ".xls")

                    Using hw As HtmlTextWriter = New HtmlTextWriter(sw)

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend