You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace MultiTerm.Wpf.CustomControl;
|
|
|
|
public class ExtendedTabControl : TabControl
|
|
{
|
|
public static readonly RoutedEvent AddButtonClickedEvent;
|
|
|
|
#region Dotnet Properties
|
|
/// <summary>
|
|
/// .NET Property for <see cref="AddButtonClickedEvent"/>
|
|
/// </summary>
|
|
public event RoutedEventHandler AddButtonClicked
|
|
{
|
|
add { this.AddHandler(AddButtonClickedEvent, value); }
|
|
remove { this.RemoveHandler(AddButtonClickedEvent, value); }
|
|
}
|
|
#endregion
|
|
|
|
static ExtendedTabControl()
|
|
{
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(ExtendedTabControl), new FrameworkPropertyMetadata(typeof(ExtendedTabControl)));
|
|
|
|
AddButtonClickedEvent = EventManager.RegisterRoutedEvent("AddButtonClicked",
|
|
RoutingStrategy.Bubble, typeof(RoutedEventArgs),
|
|
typeof(ExtendedTabControl));
|
|
}
|
|
|
|
public override void OnApplyTemplate()
|
|
{
|
|
base.OnApplyTemplate();
|
|
|
|
// get button from template
|
|
if (GetTemplateChild("addButton") is Button button)
|
|
{
|
|
button.Click += OnAddButtonClicked; ;
|
|
}
|
|
}
|
|
|
|
private void OnAddButtonClicked(object sender, RoutedEventArgs e)
|
|
{
|
|
RoutedEventArgs args = new(AddButtonClickedEvent);
|
|
RaiseEvent(args);
|
|
}
|
|
}
|
|
|