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

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

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

Posted By:      Posted Date: October 02, 2010    Points: 0   Category :WPF

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

This code snippet works but I use



private ObservableCollection<

View Complete Post

More Related Resource Links

ListViewControl - how to group items by their value, for eg. date range



I have a table containing courses, columns are 

Name - "Yoga Classes"

DateStart - "2/23/2010"

DateEnd - "2/24/2010"

I am using ListView Control to bind it, is there a way to display them and group them by Month? 

for eg.


Piano Class (10th Jan 2010 - 11th Jan 2010)
Guitar Class (10th Jan 2010 - 11th Jan 2010)


Yoga Class (15th Feb 2010 - 16th Feb 2010)

Thanks for help.

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

SSAS 2008 attritube hierarchy doesn't group records and repeat rows

We are having problems with the dimension attributes in lower level hierarchies not grouping under 1 single level. Here is the hierarchy: VP    College      Department         Departmental Course            Course Level               Course Number The top 3 levels are grouping correctly without duplicate rows and they don't have compoud keys. The lowest 3 levels are not grouped correctly and they have compounds keys because the attributes are not unique by themself. The result of the hierarchy looks like this: VP Academic Affairs    Business School of Management        International Business School            Mgm101                 Lower                       Course Number 123            Mgm101                Upper                

Animate listbox items from ItemTemplate

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.  

In a group calendar, can items be made visiable to all users by default without adding them as atten

Well the title says it all really. We have a functioning sp 2010 site, setup this weekend, that's working great so far.  Primarily its being used for the company manual and procedures (a wiki site).  Search is working well and so on. I added a calendar with the intention of showing key company activities, plus holiday information and who's out at meetings.  We're a small company and this is unlikely to get ridiculously except on exceptional days. As it stands, when i create an item (for example someone out for a weeks holiday) unless another user adds one of the 'attendees' of the holiday event to the calendar it doesn't show up.  If I add all users as attendees then they can all see it by default. However, if I show that our chairman is attending a meeting at a client, then I can't explicitly say that the chairman is an attendee because for everyone to see it, they have to be attendees as well. I nsoed around a little and thought target audiences might be the way to go.  I configured all users and manager relationships, compiled the audience (it shows the right number of users).  However, if I setup a meeting with the chairman as an attendee, and the whole company audience as the target audience, then people still can't see it. Back to square one. So, is there an actual answer to this?  A different type of calendar, a query that

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.

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?


How can I clear all selected items of a radio button group in WPF - MVVM?

Hi I have a group of radio buttons bound to a property in View model. Now, on check of one of the button, i perform some action through property. My use case is when ever the action is failed, i want to reset checked button and set the earlier one. For this, i have reset the property value in seter itself but it is not reflected on UI. A workaround for this would be to clear all checked buttons from radio button group. How can we achieve it?? thanks in advance Swapnil

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)

Extending a ListBox Control - How to make the extended type require the listbox items implement a ch


I am working on a drag and droppable timeline control, and I am making decent progress.  What I have so far will work decently enough with MVVM design patterns, but I am inexperienced with this kind of advanced control extending so I am sure that some of my methods are crude at best.

I have an extended content presenter control that I want to ensure is what is actually used inside my specialized listbox.  Right now I do the following:

<DataTemplate x:Key="TempTemplate" DataType="{x:Type local:TempDataType}">

			<tt:TimeLineItemControl StartTime="{Binding Path=StartTime}

Menu1_MenuItemClick doesn't work for items other then the first one


I got a menu server control with 2 items and each items got its own childItems

MI3.Text = City;
MI3.Value = City;

MI.Text = CityName;
MI.Value = CiTyName;

MI.Text = Country;

MI.Value = Country;
MI.Text = CountryName;
MI.Value = CountryName;

protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
        string selectedItem = Menu1.SelectedItem.Text;



If I select from the dropdownmenu city it will stop inside the menuItemClick code... but, if I select anything from the Country menu... it doesn't...

Can someone give me some help?




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