improved tabcontrol

This commit is contained in:
NaBian committed 2019-05-16 22:59:48 +08:00
1 parent 452dc847d7
commit 24612e0e5e
7 files changed
+147 -40

No files matched your search

@@ -292,6 +292,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SearchBarDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SideMenuDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\StepBarDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\TabControlDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\WindowDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\DemoViewModelBase!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Main\ContributorsViewModel.cs" />
@@ -2,12 +2,22 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="{DynamicResource RegionBrush}"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl">
DataContext="{Binding TabControlDemo,Source={StaticResource Locator}}"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl">
<controls:TransitioningContentControl>
<controls:ScrollViewer HorizontalScrollBarVisibility="Auto">
<interactivity:Interaction.Triggers>
<interactivity:RoutedEventTrigger RoutedEvent="controls:TabItem.Closing">
<interactivity:EventToCommand Command="{Binding ClosingCmd}" PassEventArgsToCommand="True" />
</interactivity:RoutedEventTrigger>
<interactivity:RoutedEventTrigger RoutedEvent="controls:TabItem.Closed">
<interactivity:EventToCommand Command="{Binding ClosedCmd}" PassEventArgsToCommand="True" />
</interactivity:RoutedEventTrigger>
</interactivity:Interaction.Triggers>
<StackPanel>
<Label Style="{StaticResource LabelPrimary}" Content="Default" Margin="32,32,0,0" HorizontalAlignment="Left"/>
<controls:TabControl Margin="32,16,32,0" Width="800" Height="300" IsScrollable="True">
<controls:TabControl ShowOverflowButton="False" ShowScrollButton="True" Margin="32,16,32,0" Width="800" Height="300" IsScrollable="True">
<controls:TabItem Header="TabItem1">
<controls:SimplePanel Background="White"/>
</controls:TabItem>
@@ -0,0 +1,32 @@
using System;
using System.Windows;
using GalaSoft.MvvmLight;
using HandyControl.Controls;
using HandyControl.Data;
#if netle40
using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
namespace HandyControlDemo.ViewModel
{
public class TabControlDemoViewModel : ViewModelBase
{
public RelayCommand<CancelRoutedEventArgs> ClosingCmd => new Lazy<RelayCommand<CancelRoutedEventArgs>>(() =>
new RelayCommand<CancelRoutedEventArgs>(Closing)).Value;
private void Closing(CancelRoutedEventArgs args)
{
Growl.Info($"{(args.OriginalSource as TabItem)?.Header} Closing");
}
public RelayCommand<RoutedEventArgs> ClosedCmd => new Lazy<RelayCommand<RoutedEventArgs>>(() =>
new RelayCommand<RoutedEventArgs>(Closed)).Value;
private void Closed(RoutedEventArgs args)
{
Growl.Info($"{(args.OriginalSource as TabItem)?.Header} Closed");
}
}
}
@@ -34,6 +34,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register<InteractiveDialogViewModel>();
SimpleIoc.Default.Register<BadgeDemoViewModel>();
SimpleIoc.Default.Register<SideMenuDemoViewModel>();
SimpleIoc.Default.Register<TabControlDemoViewModel>();
}
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -75,6 +76,8 @@ namespace HandyControlDemo.ViewModel
public SideMenuDemoViewModel SideMenuDemo => ServiceLocator.Current.GetInstance<SideMenuDemoViewModel>();
public TabControlDemoViewModel TabControlDemo => ServiceLocator.Current.GetInstance<TabControlDemoViewModel>();
#endregion
}
}