mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Working ColorPickerUserControl
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
SelectedItem="{Binding SelectedItem}"
|
SelectedItem="{Binding SelectedItem}"
|
||||||
SelectedValue="{Binding SelectedColor, ElementName=UserControl}"
|
SelectedValue="{Binding SelectedColor, ElementName=UserControl}"
|
||||||
SelectedValuePath="ColorBrush"
|
SelectedValuePath="ColorBrush"
|
||||||
Loaded="ComboBox_OnLoaded"
|
|
||||||
SelectionChanged="ComboBox_OnSelectionChanged"
|
SelectionChanged="ComboBox_OnSelectionChanged"
|
||||||
IsEnabled="{Binding IsEnabled, ElementName=UserControl}">
|
IsEnabled="{Binding IsEnabled, ElementName=UserControl}">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System.Linq;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
@@ -10,8 +9,6 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
{
|
{
|
||||||
public sealed partial class ColorPickerUserControl
|
public sealed partial class ColorPickerUserControl
|
||||||
{
|
{
|
||||||
private ColorPickerControlVm Model => ComboBox.DataContext as ColorPickerControlVm;
|
|
||||||
|
|
||||||
public SolidColorBrush SelectedColor
|
public SolidColorBrush SelectedColor
|
||||||
{
|
{
|
||||||
get { return (SolidColorBrush)GetValue(SelectedColorProperty); }
|
get { return (SolidColorBrush)GetValue(SelectedColorProperty); }
|
||||||
@@ -22,22 +19,21 @@ namespace ModernKeePass.Views.UserControls
|
|||||||
nameof(SelectedColor),
|
nameof(SelectedColor),
|
||||||
typeof(SolidColorBrush),
|
typeof(SolidColorBrush),
|
||||||
typeof(ColorPickerUserControl),
|
typeof(ColorPickerUserControl),
|
||||||
new PropertyMetadata(new SolidColorBrush(), (o, args) => { }));
|
new PropertyMetadata(new SolidColorBrush(), (o, args) =>
|
||||||
|
{
|
||||||
|
var colorPickerUserControl = o as ColorPickerUserControl;
|
||||||
|
var vm = colorPickerUserControl?.ComboBox.DataContext as ColorPickerControlVm;
|
||||||
|
vm?.Initialize(args.NewValue as SolidColorBrush);
|
||||||
|
}));
|
||||||
|
|
||||||
public ColorPickerUserControl()
|
public ColorPickerUserControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBox_OnLoaded(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Model.Initialize(SelectedColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void ComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.RemovedItems.Any())
|
SelectedColor = (e.AddedItems[0] as ColorPickerControlVm.Color)?.ColorBrush;
|
||||||
SelectedColor = ComboBox.SelectedValue as SolidColorBrush;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user