 |
|
 |
Is possible use this control in Silverlight 2? Add the reference is not possible beacause it's debug for wpf. I'm searching a workaround to use the splitbutton in Silverlight..any idea or someone know this control created for Silverlight??
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks man!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for posting this article. I really like it.
I'm using this with vs2008, SP1 and I'm having a couple problems.
1. The SplitButton project has a reference to Microsoft.Windows.Design.Markup which is not found on my system, but it doesn't seem to prevent me from running the demo. 2. I tried changing the mode to Dropdowm (see below) from the default Split and when I click anywhere on the button, nothing drops down.
<m:SplitButton Mode="Dropdown" Margin="0,1,0,1" Padding="5,0,5,0" Placement="Bottom" HorizontalAlignment="Center" VerticalAlignment="Center" Height="24" Click="SplitButton_Click" Style="{DynamicResource {x:Static m:SplitButtonResources.VistaSplitButtonStyleKey}}"> <m:SplitButton.Content> <StackPanel Orientation="Horizontal"> <Image Source="Icons\mail.ico" Width="16" Height="16"/> <TextBlock Text="Send/Receive" Margin="3,0,0,0"/> </StackPanel> </m:SplitButton.Content> <MenuItem Header="Send and receive _all"/> <MenuItem Header="Receive All"/> <MenuItem Header="Send All"/> <Separator/> <MenuItem Header="Hotmail (Default)"/> <MenuItem Header="Gmail"/> </m:SplitButton>
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I figured out one way to make it behave as a true dropdown with the left click. Just modify your application's click handler for the button as follows:
private void SplitButton_Click(object sender, RoutedEventArgs e) {
if (((SplitButton)sender).Mode == SplitButtonMode.Dropdown) { ((SplitButton)sender).ContextMenu.PlacementTarget = (SplitButton)sender; ((SplitButton)sender).ContextMenu.IsOpen = true;
e.Handled = true; return; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi ssing
thanks for pointing out the bug, I haven't looked at this for a while, I'm surprised no one else has spotted the error, possibly no one uses it in DropDown Mode, anyway I've uploaded a fix to codeproject.
thanks again. Alan...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Very nice control, thanks for sharing it!
When I first tested the SplitButton control, my instinct was to click the drop-down button to open the context menu (so I could see the available items), then click it again to close it. I was surprised to discover that this sometimes resulted in the default click event getting fired (showing the "Click event handler" dialog). I realized this happened when the mouse pointer hotspot is directly over the "path" Path object. In this case the Path object named "path" receives the click and passes it to the underlying default button rather than the drop-down button the user intended. This is easily fixed by declaring the "path" Path object *before* the drop-down button in the XAML rather than after (thus placing it lower in the Z order). If you do that, I don't think you even need the MouseOver Trigger that sets the "path" Path's Visibility=Collapsed.
I would still like to figure out how to get the drop down menu to close when you click the drop-down button when the menu is already open, but haven't figured out a good way to accomplish this, any suggestions?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi matt, thanks for your comments,
I've updated the code to include your suggestions for the z-order of the path object, this seems to have fixed the bug you described,
I've also implemented the feature to close the context menu if open when clicking the button for a second time.
Regards Alan...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
That's great! Where can I get the updated code? The link at the top of the project page still seems to be the old version.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hi all, this is my first post so be kind 
When using this control in a "button bar" type menu I found myself needing a version of the control that had the same Vista style but fuctioned like a normal button (without the drop-down/split).
I made a few simple changes to the code to allow a "Button" mode to be set which removes the split/dropdown from the control.
I know one could just create a new Vista style based on the current style and remove the dropdown portion. Doing so however, would require maintaining two copies of the main style components and make style changes/tweaking more cumbersome.
So here are the changes: (These only affect the Vista style!)
SplitButton.cs
I added the Button value to the enum as follows
public enum SplitButtonMode { Split, Dropdown, Button }
Vista.xaml
I changed the Width="16" to Width="Auto" in the second ColumnDefinition and added the width to outerBorder2. This allows outerBorder2 to be collapsed taking the width of 16 with it.
<ControlTemplate TargetType="{x:Type local:SplitButton}">
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions>
...
<!-- Dropdown Button Border--> <Border x:Name="outerBorder2" Width="16" Margin="-1,0,0,0" Grid.Column="1" Style="{DynamicResource outerBorderNormal}"> <Border x:Name="innerBorder2" Style="{DynamicResource innerBorderNormal}"/> </Border>
Finally I added a new trigger for the "Button" mode to the end of ControlTemplate.Triggers.
<Trigger Property="Mode" Value="Button"> <Setter Property="Visibility" TargetName="PART_DropDown" Value="Collapsed"/> <Setter Property="Visibility" TargetName="outerBorder2" Value="Collapsed"/> </Trigger>
Well that's it. Now you can set Mode="Button" on the SplitButton control and a normal button using the same Vista style will result.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
When I put this splitbutton in a toolbar, it still looks like a regular button on a form. Any other buttons on the same toolbar look like differently on my XP Pro machine. (They look like labels, until you hover on them, then they turn blue with a border.) Do you know of a way to instruct this to use the style that toolbar uses to render a normal button.
Code would look something like this to see the difference:
<Grid> <ToolBar VerticalAlignment="Top"> <Button Content="Hello"/> <m:SplitButton Content="Split Button"/> </ToolBar> </Grid>
I sure would appreciate any of your thoughts on the matter.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I thought this would be achieved by using DropDown mode. However, it is not quite right because left click on mouse does nothing. Drop-down only appears for right click on Mouse. Am still trying to finger out how to modify to become a standard left click drop down button.
Regards John S
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
John,
Have you figured out how to turn this into a standard left-click drop down button? I'm looking to solve the same problem. Thanks!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
This is probably way past being useful to you by now but I did figure out a way to make it behave as a true dropdown with left click. Just change the click handler in your application as follows:
private void SplitButton_Click(object sender, RoutedEventArgs e) {
if (((SplitButton)sender).Mode == SplitButtonMode.Dropdown) { ((SplitButton)sender).ContextMenu.PlacementTarget = (SplitButton)sender; ((SplitButton)sender).ContextMenu.IsOpen = true;
e.Handled = true; return; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I tried to place your Splitbutton inside a Toolbutton. Its firing error as,
The assembly used when compiling might be different than that used when loading and the type is missing. Error at object 'System.Windows.Controls.ToolBar' in markup file
Do you have any idea about this error message?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I really like this control and want to use it, but I would prefer to merge it into an existing project rather than having it in a project of its own.
I copied the Themes folder and the other three files to a sub-folder in another project. I changed all of the namespaces to match my current project and added the necessary references.
The Problem: I was able to add and configure a new SplitButton to a WPF Window, but the button is not visible at design or run time. I can see the outline of the button when I select the button's XAML code, but that's it. The project compiles fine.
Any ideas on what the problem might be? Your help would be greatly appreciated.
Thanks, Joe Puccia
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello Joe,
Just to let you know that I faced the same problem and found a solution.
Check this blog entry: http://wangmo.wordpress.com/2007/09/27/themesgenericxaml/[^]
Checklist:
- Copy the themes to a folder "Themes" in your application - Change all theme .xaml files, by updating the reference to your assembly to something like
xmlns:local="clr-namespace:TheNamespaceWhereTheControlIsLocated" - Change resource dictionary merge in file generic.xaml like this:
<ResourceDictionary Source="component/themes/Vista.xaml"/> - Change the assembly info so that you get the resource dictionaries from the source assembly
[assembly: ThemeInfo( ResourceDictionaryLocation.SourceAssembly, ResourceDictionaryLocation.SourceAssembly)]
Hope it helps
Cheers, - xico -
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi I've downloaded your sample But On my maschine I can trun it:
Error 1 The name 'InitializeComponent' does not exist in the current context C:\Dokumente und Einstellungen\hkl\Desktop\SplitButton\SplitButton\Demo\Window1.xaml.cs 13 13 Demo
Can you upload a running version for WinXP? Best regards
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Horst
This control was developed and uploaded from a windows xp machine, so i don't think that is the problem.
unfortunately i don't have vs2005, the project was written using the VS2008 beta 2 bits. I assume you have the WPF extensions for vs2005 installed and the dotnet framework 3.0, if so then I don't really know how else to help you.
regards Alan
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Alan
Thanks for the swift feedback. Yes, I have installed all the nessasary WPF extensions and the 3.0 framework. I'm working on a WPF application  Good to know, you use also a XP machine.
Well, I don't have time at the moment to find the reason why it's not working with VS2005. Do you uses framework 3.5 features?
@any other readers: Who can run the sample with VS2005?
Best regards Horst
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Horst
Horst Klein wrote: Do you uses framework 3.5 features?
No. both the demo and SplitButton project's target framework are set to 3.0
Are all the PresentationFramework references in place.
you should have references for PresentationCore PresentationFramework PresentationFramework.Aero PresentationFramework.Classic PresentationFramework.Luna PresentationFramework.Royale
in both projects
regards Alan
-- modified at 13:27 Friday 23rd November, 2007
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |