mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Finally a nicer looking and working TextBoxWithButton (inspired from the SearchButton)
SearchBox field style improved
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace ModernKeePass.Controls
|
||||
{
|
||||
public class TextBoxWithButton : TextBox
|
||||
public class TextBoxWithButton : Control
|
||||
{
|
||||
public event EventHandler<RoutedEventArgs> ButtonClick;
|
||||
|
||||
@@ -15,7 +16,7 @@ namespace ModernKeePass.Controls
|
||||
}
|
||||
public static readonly DependencyProperty ButtonSymbolProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonSymbol",
|
||||
nameof(ButtonSymbol),
|
||||
typeof(string),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata("", (o, args) => { }));
|
||||
@@ -27,11 +28,46 @@ namespace ModernKeePass.Controls
|
||||
}
|
||||
public static readonly DependencyProperty ButtonTooltipProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonTooltip",
|
||||
nameof(ButtonTooltip),
|
||||
typeof(string),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(string.Empty, (o, args) => { }));
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return (string)GetValue(TextProperty); }
|
||||
set { SetValue(TextProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TextProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(Text),
|
||||
typeof(string),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(string.Empty, (o, args) => { }));
|
||||
public string PlaceholderText
|
||||
{
|
||||
get { return (string)GetValue(PlaceholderTextProperty); }
|
||||
set { SetValue(PlaceholderTextProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty PlaceholderTextProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(PlaceholderText),
|
||||
typeof(string),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(string.Empty, (o, args) => { }));
|
||||
|
||||
public ICommand ButtonCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(ButtonCommandProperty); }
|
||||
set { SetValue(ButtonCommandProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ButtonCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(ButtonCommand),
|
||||
typeof(ICommand),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public bool IsButtonEnabled
|
||||
{
|
||||
get { return (bool)GetValue(IsButtonEnabledProperty); }
|
||||
@@ -44,6 +80,11 @@ namespace ModernKeePass.Controls
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(true, (o, args) => { }));
|
||||
|
||||
|
||||
public TextBoxWithButton()
|
||||
{
|
||||
DefaultStyleKey = typeof(TextBoxWithButton);
|
||||
}
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
Reference in New Issue
Block a user