I use this class, and it looks great: andyonwpf.blogspot.com/2006/10/dropdownb....
I use this class, and it looks great: andyonwpf.blogspot.com/2006/10/dropdownb..." rel="nofollow">andyonwpf.blogspot.com/2006/10/dropdownb... I will post here so it's cleaner to read: /// /// Andy On WPF: DropDownButtons in WPF /// andyonwpf.blogspot.com/2006/10/dropdownb..." rel="nofollow">andyonwpf.blogspot.com/2006/10/dropdownb... /// public class DropDownButton : ToggleButton { #region Members public enum Placement { Bottom, Right } #endregion #region Properties #region DropDownPlacement /// /// DropDown placement. /// public Placement DropDownPlacement { get { return (Placement)GetValue(DropDownPlacementProperty); } set { SetValue(DropDownPlacementProperty, value); } } /// /// DropDown placement (Dependency Property). /// public static readonly DependencyProperty DropDownPlacementProperty = DependencyProperty.
Register("DropDownPlacement", typeof(Placement), typeof(DropDownButton), new UIPropertyMetadata(null)); #endregion #region DropDown /// /// DropDown property. /// public ContextMenu DropDown { get { return (ContextMenu)GetValue(DropDownProperty); } set { SetValue(DropDownProperty, value); } } /// /// DropDown property (Dependency property). /// public static readonly DependencyProperty DropDownProperty = DependencyProperty.
Register("DropDown", typeof(ContextMenu), typeof(DropDownButton), new PropertyMetadata(null, OnDropDownChanged)); #endregion #endregion #region Events private static void OnDropDownChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ((DropDownButton)sender). OnDropDownChanged(e); } void OnDropDownChanged(DependencyPropertyChangedEventArgs e) { if (DropDown! = null) { DropDown.
PlacementTarget = this; switch (DropDownPlacement) { default: case Placement. Bottom: DropDown. Placement = PlacementMode.
Bottom; break; case Placement. Right: DropDown. Placement = PlacementMode.
Right; break; } this. Checked += new RoutedEventHandler((a, b) => { DropDown. IsOpen = true; }); this.
Unchecked += new RoutedEventHandler((a, b) => { DropDown. IsOpen = false; }); DropDown. Closed += new RoutedEventHandler((a, b) => { this.
IsChecked = false; }); } } #endregion }.
I think this is the most decent way to do this. Thanks :) – Allan Chua Dec 14 at 5:13.
It has a custom control template, one that appears to have a transparent background unless on mouse-over, of course the gradient and border is different too. On MSDN there is an example for a custom template which results in a rather blue button, basically you can do anything with the templates, their creation can be quite some work though. Expression Blend can be helpful for control templating.
Yes, I know already know that this is a control template, but do you have an idea what are the ControlElemets will be used here :) – Allan Chua Dec 7 at 0:36 It could be all kinds of controls, I think the default template of the button might be a good start for the basic appearance, but you probably want to template a Menu and MenuItem because of the functionality. If you have some idea how to create a template which includes knowledge of the states, PARTs etc. You should be able to recreate this, it's not like you need to stay true to the actual internals used in Windows. – H.B. Dec 7 at 0:46 You have a point there :), Recreating this template in my own way would satisfy the problem.
But I'm still curious what could had been used by microsoft guys here. Thanks anyways +1 for you – Allan Chua Dec 7 at 0:51.
To get the menu part of the dropdown you can set the button's ContextMenu property and then use the ContextMenu. Placement to position it correctly underneath the button. You may also have to set ContextMenu.
PlacementTarget to keep it relative to the Button.
Uhmm.. this is also a good idea maybe a routed event may help by this method.. thanks +1 to you – Allan Chua Dec 7 at 1:19 1 You can implement the Click event of the Button to get the menu to drop down on a left mouse click. – JayP Dec 7 at 1:36 I don't know about this, it is conceptually a menu, and the buttons are top level menuitems that just look a little different, I would not bend a button to provide a functionality it was not meant for. – H.B.Dec 7 at 3:26.
Sorry for adding again, but I just realized this control also exists in the Extended WPF Toolkit on Codeplex: wpftoolkit.codeplex.com/wikipage?title=D... It implements like this (as per their site): You can just add MenuItems in there as needed. I have used this kit for other features (ChildWindow and SplitButton), and I think it's well done. Keep expecting more like this from CodePlex and Microsoft as people keep requesting more Office 2007 / 2010 functionality in WPF.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.