|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionAs the Windows Presentation Foundation (WPF) does not have a split button built-in, I decided to have a go at writing one. As I am fairly new to this Framework, I wanted something simple to start with, and this is what I came up with. Although it would be possible to create a split button using Styles and Control Templates, I wanted to support the Windows Themes so a custom control seemed like the way to go. The Control derives from Using the CodeTo add a split button to a window, reference the assembly, then add an XML xmlns:m="clr-namespace:Wpf.Controls;assembly=Wpf.SplitButton"
The XAML below adds a split button to a window and shows how to add <m:SplitButton Content="Split Button" Placement="Bottom">
<MenuItem Header="MenuItem 1"/>
<MenuItem Header="MenuItem 2">
<MenuItem Header="MenuItem 1"/>
<MenuItem Header="MenuItem 2"/>
</MenuItem>
</m:SplitButton
The control assembly has a style defined for each of the Windows themes. To draw the control, I've used the Style="{DynamicResource {x:Static m:SplitButtonResources.VistaSplitButtonStyleKey}}"
Vista Styled Button with an Icon
Points of InterestAs shown above, the To place the context menu, use the The IssuesThis control was developed using the Beta2 release of Visual Studio 2008. Unfortunately the demo project does not display in the cider designer (for me anyway). This may be a bug in Visual Studio as it displays fine in Expression Blend and compiles and runs without problems. History24-Sept-2007: Article posted02-Oct-2007: Article updated
09-Oct-2007: Article updated
20-Oct-2007: Article updated
|
||||||||||||||||||||||