2017-10-12 17:30:29 +02:00
|
|
|
|
using System;
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Controls
|
|
|
|
|
{
|
|
|
|
|
public class TextBoxWithButton : TextBox
|
|
|
|
|
{
|
2017-11-27 15:26:36 +01:00
|
|
|
|
public string ButtonSymbol
|
2017-11-06 19:01:01 +01:00
|
|
|
|
{
|
2017-11-27 15:26:36 +01:00
|
|
|
|
get { return (string)GetValue(ButtonSymbolProperty); }
|
2017-11-06 19:01:01 +01:00
|
|
|
|
set { SetValue(ButtonSymbolProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty ButtonSymbolProperty =
|
|
|
|
|
DependencyProperty.Register(
|
|
|
|
|
"ButtonSymbol",
|
2017-11-27 15:26:36 +01:00
|
|
|
|
typeof(string),
|
2017-11-06 19:01:01 +01:00
|
|
|
|
typeof(TextBoxWithButton),
|
2017-11-27 15:26:36 +01:00
|
|
|
|
new PropertyMetadata("", (o, args) => { }));
|
|
|
|
|
public event EventHandler<RoutedEventArgs> ButtonClick;
|
2017-11-06 19:01:01 +01:00
|
|
|
|
|
2017-11-27 15:26:36 +01:00
|
|
|
|
public string ButtonTooltip
|
2017-11-06 19:01:01 +01:00
|
|
|
|
{
|
2017-11-27 15:26:36 +01:00
|
|
|
|
get { return (string)GetValue(ButtonTooltipProperty); }
|
|
|
|
|
set { SetValue(ButtonTooltipProperty, value); }
|
2017-11-06 19:01:01 +01:00
|
|
|
|
}
|
2017-11-27 15:26:36 +01:00
|
|
|
|
public static readonly DependencyProperty ButtonTooltipProperty =
|
2017-11-06 19:01:01 +01:00
|
|
|
|
DependencyProperty.Register(
|
2017-11-27 15:26:36 +01:00
|
|
|
|
"ButtonTooltip",
|
2017-11-06 19:01:01 +01:00
|
|
|
|
typeof(string),
|
|
|
|
|
typeof(TextBoxWithButton),
|
2017-11-27 15:26:36 +01:00
|
|
|
|
new PropertyMetadata(string.Empty, (o, args) => { }));
|
2017-10-12 17:30:29 +02:00
|
|
|
|
|
|
|
|
|
protected override void OnApplyTemplate()
|
|
|
|
|
{
|
|
|
|
|
base.OnApplyTemplate();
|
2017-11-06 19:01:01 +01:00
|
|
|
|
var actionButton = GetTemplateChild("ActionButton") as Button;
|
|
|
|
|
if (actionButton != null)
|
2017-10-12 17:30:29 +02:00
|
|
|
|
{
|
2017-11-06 19:01:01 +01:00
|
|
|
|
actionButton.Click += (sender, e) => ButtonClick?.Invoke(sender, e);
|
2017-10-12 17:30:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|