Merge pull request #172 from HandyOrg/add-SplitButton

Add split button
This commit is contained in:
NaBian authored and GitHub committed 2019-09-17 00:50:13 +08:00
commit 1cc89b2849
44 files changed
+524 -92

No files matched your search

@@ -53,6 +53,16 @@ namespace HandyControlDemo
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
});
Current.MainWindow?.OnApplyTemplate();
Resources.MergedDictionaries.Clear();
Resources.MergedDictionaries.Add(new ResourceDictionary
{
Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin.ToString()}.xaml")
});
Resources.MergedDictionaries.Add(new ResourceDictionary
{
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
});
}
}
}
@@ -116,6 +116,8 @@
public static readonly string FloatingBlockDemoCtl = nameof(FloatingBlockDemoCtl);
public static readonly string SplitButtonDemoCtl = nameof(SplitButtonDemoCtl);
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl);
@@ -60,7 +60,8 @@ var controlList = new List<string>
"HoneycombPanelDemoCtl",
"SpriteDemoCtl",
"NotificationDemoCtl",
"FloatingBlockDemoCtl"
"FloatingBlockDemoCtl",
"SplitButtonDemoCtl"
};
var styleList = new List<string>
{
@@ -183,6 +183,9 @@
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\SideMenuDemoCtl.xaml.cs">
<DependentUpon>SideMenuDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\SplitButtonDemoCtl.xaml.cs">
<DependentUpon>SplitButtonDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\SpriteDemoCtl.xaml.cs">
<DependentUpon>SpriteDemoCtl.xaml</DependentUpon>
</Compile>
@@ -338,6 +341,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\PaginationDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SearchBarDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SideMenuDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SplitButtonDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SpriteDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\StepBarDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\TabControlDemoViewModel.cs" />
@@ -621,6 +625,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\SplitButtonDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\SpriteDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -1401,6 +1401,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 分割按钮 的本地化字符串。
/// </summary>
public static string SplitButton {
get {
return ResourceManager.GetString("SplitButton", resourceCulture);
}
}
/// <summary>
/// 查找类似 精灵 的本地化字符串。
/// </summary>
@@ -663,4 +663,7 @@
<data name="FloatingBlock" xml:space="preserve">
<value>FloatingBlock</value>
</data>
<data name="SplitButton" xml:space="preserve">
<value>SplitButton</value>
</data>
</root>
@@ -663,4 +663,7 @@
<data name="FloatingBlock" xml:space="preserve">
<value>FloatingBlock</value>
</data>
<data name="SplitButton" xml:space="preserve">
<value>SplitButton</value>
</data>
</root>
@@ -663,4 +663,7 @@
<data name="FloatingBlock" xml:space="preserve">
<value>FloatingBlock</value>
</data>
<data name="SplitButton" xml:space="preserve">
<value>SplitButton</value>
</data>
</root>
@@ -663,4 +663,7 @@
<data name="FloatingBlock" xml:space="preserve">
<value>漂浮块</value>
</data>
<data name="SplitButton" xml:space="preserve">
<value>分割按钮</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

@@ -0,0 +1,39 @@
<UserControl x:Class="HandyControlDemo.UserControl.SplitButtonDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
DataContext="{Binding SplitButtonDemo,Source={StaticResource Locator}}">
<hc:TransitioningContentControl>
<StackPanel Margin="32" VerticalAlignment="Center">
<hc:SplitButton Margin="0,0,0,10" Content="{x:Static langs:Lang.Default}" Command="{Binding SelectCmd}" CommandParameter="Command0" HorizontalAlignment="Stretch">
<hc:SplitButton.DropDownContent>
<StackPanel>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command1"/>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command2"/>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command3"/>
</StackPanel>
</hc:SplitButton.DropDownContent>
</hc:SplitButton>
<hc:SplitButton Style="{StaticResource SplitButtonPrimary}" Margin="0,0,0,10" Content="{x:Static langs:Lang.Primary}" Command="{Binding SelectCmd}" CommandParameter="Command0" HorizontalAlignment="Stretch">
<hc:SplitButton.DropDownContent>
<StackPanel>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command1"/>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command2"/>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command3"/>
</StackPanel>
</hc:SplitButton.DropDownContent>
</hc:SplitButton>
<hc:SplitButton Style="{StaticResource SplitButtonWarning}" Margin="0,0,0,10" Content="{x:Static langs:Lang.Warning}" HitMode="Hover" HorizontalAlignment="Stretch">
<hc:SplitButton.DropDownContent>
<StackPanel>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command1"/>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command2"/>
<MenuItem Header="{x:Static langs:Lang.Title}" Command="{Binding SelectCmd}" CommandParameter="Command3"/>
</StackPanel>
</hc:SplitButton.DropDownContent>
</hc:SplitButton>
</StackPanel>
</hc:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,17 @@
using System.Windows;
namespace HandyControlDemo.UserControl
{
public partial class SplitButtonDemoCtl
{
public SplitButtonDemoCtl()
{
InitializeComponent();
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
MessageBox.Show("123");
}
}
}
@@ -225,6 +225,11 @@
<Image Source="../../Resources/Img/LeftMainContent/GoToTop_16x.png"/>
</hc:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.SplitButtonDemoCtl}" Content="{x:Static langs:Lang.SplitButton}">
<hc:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/SplitButton_16x.png"/>
</hc:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Tag="{x:Static data:MessageToken.ButtonGroupDemoCtl}" Content="{x:Static langs:Lang.ButtonGroup}">
<hc:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/ButtonGroup_16x.png"/>
@@ -330,7 +335,7 @@
<Image Source="../../Resources/Img/LeftMainContent/TextBlock_16x.png"/>
</hc:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.RunningBlockDemoCtl}" Content="{x:Static langs:Lang.RunningBlock}">
<ListBoxItem Tag="{x:Static data:MessageToken.RunningBlockDemoCtl}" Content="{x:Static langs:Lang.RunningBlock}">
<hc:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Dynamic_16x.png"/>
</hc:EdgeElement.LeftContent>
@@ -0,0 +1,17 @@
using System;
using GalaSoft.MvvmLight;
using HandyControl.Controls;
#if netle40
using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
namespace HandyControlDemo.ViewModel
{
public class SplitButtonDemoViewModel : ViewModelBase
{
public RelayCommand<string> SelectCmd => new Lazy<RelayCommand<string>>(() =>
new RelayCommand<string>(str => Growl.Info(str))).Value;
}
}
@@ -39,6 +39,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register<CardDemoViewModel>();
SimpleIoc.Default.Register<SpriteDemoViewModel>();
SimpleIoc.Default.Register<NotificationDemoViewModel>();
SimpleIoc.Default.Register<SplitButtonDemoViewModel>();
}
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -94,6 +95,8 @@ namespace HandyControlDemo.ViewModel
public NotificationDemoViewModel NotificationDemo => ServiceLocator.Current.GetInstance<NotificationDemoViewModel>();
public SplitButtonDemoViewModel SplitButtonDemo => ServiceLocator.Current.GetInstance<SplitButtonDemoViewModel>();
#endregion
}
}