mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
ColorPickerControl finally doesn't set database to dirty when there is an initial value
This commit is contained in:
@@ -6,10 +6,14 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<ComboBox x:Name="ComboBox"
|
||||
ItemsSource="{Binding Colors, ElementName=UserControl}"
|
||||
SelectedValue="{Binding SelectedColor, ElementName=UserControl, Mode=TwoWay}"
|
||||
SelectedValuePath="ColorBrush"
|
||||
IsEnabled="{Binding IsEnabled, ElementName=UserControl}">
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=ColorPicker}"
|
||||
ItemsSource="{Binding Colors}"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
SelectedValue="{Binding SelectedColor, ElementName=UserControl}"
|
||||
SelectedValuePath="ColorBrush"
|
||||
Loaded="ComboBox_OnLoaded"
|
||||
SelectionChanged="ComboBox_OnSelectionChanged"
|
||||
IsEnabled="{Binding IsEnabled, ElementName=UserControl}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,10,0">
|
||||
|
@@ -1,9 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
@@ -11,13 +10,7 @@ namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class ColorPickerUserControl
|
||||
{
|
||||
public struct Color
|
||||
{
|
||||
public string ColorName { get; set; }
|
||||
public SolidColorBrush ColorBrush { get; set; }
|
||||
}
|
||||
|
||||
public List<Color> Colors { get; }
|
||||
private ColorPickerControlVm Model => ComboBox.DataContext as ColorPickerControlVm;
|
||||
|
||||
public SolidColorBrush SelectedColor
|
||||
{
|
||||
@@ -34,17 +27,17 @@ namespace ModernKeePass.Views.UserControls
|
||||
public ColorPickerUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
Colors = new List<Color>();
|
||||
var type = typeof(Windows.UI.Colors);
|
||||
var properties = type.GetRuntimeProperties().ToArray();
|
||||
foreach (var propertyInfo in properties)
|
||||
{
|
||||
Colors.Add(new Color
|
||||
{
|
||||
ColorName = propertyInfo.Name,
|
||||
ColorBrush = new SolidColorBrush((Windows.UI.Color)propertyInfo.GetValue(null, null))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ComboBox_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Model.Initialize(SelectedColor);
|
||||
}
|
||||
|
||||
private void ComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.RemovedItems.Any())
|
||||
SelectedColor = ComboBox.SelectedValue as SolidColorBrush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user