Welcome to MSDN Blogs Sign in | Join | Help

WPF: Expander Dropdown

Do you ever get sick of hunting through a dropdown that has hundreds of items in no particular order.  I do!!  I've seen far too many LOB apps that feel the need to have hundreds items in a dropdown.  So this week, I created the expander dropdown to at least provide some organization to those massive dropdowns ... I have some spare time since it doesn't look like I'm going to find an XBOX 360 until next summer [:)].  I saw some of Namita's samples and that really sparked the idea, so thanks to her.

Here is the unexpanded view:

And the expanded view:

And, for all of you still with the Sept CTP like me ... I'll try embedding the sample as a web browser application. Let me know how this works.

I removed the inline web browser app -- MD

And of course, the source:

http://mattdot.members.winisp.net/Blog/ExpanderDropdown/WpfBlogSamples.zip

Published Tuesday, November 22, 2005 12:51 AM by mattdotson

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: WPF: Expander Dropdown

nice control!

another cool wpf widget might a hybrid combobox that does realtime filtering as you type (think of the search bar in itunes).

Tuesday, November 22, 2005 4:56 AM by abanker

# re: WPF: Expander Dropdown

Yeah, you could do that ... I've never used iTunes, but I think I get what you are saying. I'll post a sample soon.
Tuesday, November 29, 2005 2:32 PM by mattdotson

# re: WPF: Expander Dropdown

Could you post an updated version of the code, one that runs in the release version of the framework?

thanks,

gabo

Wednesday, January 17, 2007 1:10 PM by Gabriel Lopez

# re: WPF: Expander Dropdown

I'm working on an RTM version.  Should be available soon.

Wednesday, January 24, 2007 5:31 AM by mattdotson

# re: WPF: Expander Dropdown

Please suggest how to place dropdown controls in expander control

Thanks

Thursday, August 23, 2007 4:55 PM by Rupali

# re: WPF: Expander Dropdown

I am hosting a expander control in my WinForm appliction, thus all make-up things are done by code, not in .xaml file.

Can you suggest how to move the expander arrow from its initial left side to the right side of the window?

Friday, September 21, 2007 5:56 AM by faye

# error on opening your project

why error on this

Error 5 The tag 'Application' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/avalon/2005'. Line 1 Position 14. C:\Documents and Settings\alainlye\Desktop\c# download\dropdown\WpfBlogSamples\WpfBlogSamples\MyApp.xaml 1 14 WpfBlogSamples

also

Error 6 The tag 'Page' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/avalon/2005'. Line 4 Position 7. C:\Documents and Settings\alainlye\Desktop\c# download\dropdown\WpfBlogSamples\WpfBlogSamples\Page1.xaml 4 7 WpfBlogSamples

Sunday, December 09, 2007 10:33 PM by angel

# re: WPF: Expander Dropdown

For those interested by an update for VS2008, here is the code of Page1.xaml :

<Page x:Class="WpfBlogSamples.Page1"

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"

xmlns:local="clr-namespace:WpfBlogSamples"

   Title="WPF Samples - Expander Dropdown"

Loaded="PageLoaded"

   >

<Page.Resources>

<!-- Container Style for 1st level of grouping -->

<Style x:Key="containerStyle"  TargetType="{x:Type GroupItem}">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type GroupItem}">

<Expander IsExpanded="False" Header="{TemplateBinding Content}"

HeaderTemplate="{TemplateBinding ContentTemplate}">

<ItemsPresenter />

</Expander>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

<CollectionViewSource x:Key="GroupedData">

           <CollectionViewSource.GroupDescriptions>

               <PropertyGroupDescription PropertyName="Continent"/>

           </CollectionViewSource.GroupDescriptions>

           <CollectionViewSource.SortDescriptions>

               <scm:SortDescription PropertyName="Continent" Direction="Ascending"/>

               <scm:SortDescription PropertyName="Country" Direction="Ascending"/>

           </CollectionViewSource.SortDescriptions>

       </CollectionViewSource>

<DataTemplate x:Key="GroupHeader">

<TextBlock Text="{Binding Path=Name}" FontFamily="Myriad Pro" FontSize="20" Margin="20,5,5,5" Foreground="#989791"   />

</DataTemplate>

<DataTemplate x:Key="CountryTemplate">

           <TextBlock Text="{Binding Path=Country}" Width="{Binding RelativeSource={RelativeSource Findancestor, AncestorType={x:Type ItemsControl}}, Path=Width}" FontFamily="Myriad Pro" FontSize="16" Margin="0,0,0,0" />

</DataTemplate>

<DataTemplate x:Key="SelectedCountryTemplate">

<TextBlock Text="{Binding Path=Country}" FontFamily="Myriad Pro" FontSize="16" Margin="0,0,0,0" />

</DataTemplate>

</Page.Resources>

<StackPanel Margin="40">

<ComboBox Width="200" DataContext="{StaticResource GroupedData}" ItemsSource="{Binding}" ItemTemplate="{StaticResource CountryTemplate}">

<ComboBox.GroupStyle>

<GroupStyle ContainerStyle="{StaticResource containerStyle}" HeaderTemplate="{StaticResource GroupHeader}"/>

</ComboBox.GroupStyle>

</ComboBox>

</StackPanel>

</Page>

Thursday, August 06, 2009 6:25 AM by F£ö

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker