Files
modernkeepass/ModernKeePass/Controls/TextBoxWithButton.cs
BONNEVILLE Geoffroy 7e337c4a40 History list fully functional in Entry page
Viewing a historic entry disables controls on the page
Enhancements in the hamburger menu
2018-06-15 18:07:44 +02:00

69 lines
2.5 KiB
C#

using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace ModernKeePass.Controls
{
public class TextBoxWithButton : TextBox
{
public string ButtonSymbol
{
get { return (string)GetValue(ButtonSymbolProperty); }
set { SetValue(ButtonSymbolProperty, value); }
}
public static readonly DependencyProperty ButtonSymbolProperty =
DependencyProperty.Register(
"ButtonSymbol",
typeof(string),
typeof(TextBoxWithButton),
new PropertyMetadata("", (o, args) => { }));
public event EventHandler<RoutedEventArgs> ButtonClick;
public string ButtonTooltip
{
get { return (string)GetValue(ButtonTooltipProperty); }
set { SetValue(ButtonTooltipProperty, value); }
}
public static readonly DependencyProperty ButtonTooltipProperty =
DependencyProperty.Register(
"ButtonTooltip",
typeof(string),
typeof(TextBoxWithButton),
new PropertyMetadata(string.Empty, (o, args) => { }));
public bool IsButtonEnabled
{
get { return (bool)GetValue(IsButtonEnabledProperty); }
set { SetValue(IsButtonEnabledProperty, value); }
}
public static readonly DependencyProperty IsButtonEnabledProperty =
DependencyProperty.Register(
"IsButtonEnabled",
typeof(bool),
typeof(TextBoxWithButton),
new PropertyMetadata(true, (o, args) => { }));
public FlyoutBase ButtonFlyout
{
get { return (FlyoutBase)GetValue(ButtonFlyoutProperty); }
set { SetValue(ButtonFlyoutProperty, value); }
}
public static readonly DependencyProperty ButtonFlyoutProperty =
DependencyProperty.Register(
"ButtonFlyout",
typeof(FlyoutBase),
typeof(TextBoxWithButton),
new PropertyMetadata(null, (o, args) => { }));
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
var actionButton = GetTemplateChild("ActionButton") as Button;
if (actionButton != null)
{
actionButton.Click += (sender, e) => ButtonClick?.Invoke(sender, e);
}
}
}
}