This commit is contained in:
Holger Börchers 2020-02-28 21:32:32 +01:00
parent e6704c331f
commit 4293e60fa7
8 changed files with 17 additions and 1190 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<local:IntellisenseResources Source="/ModernWpf;component/DesignTime/DesignTimeResources.xaml" />
<local:IntellisenseResourceDictionary Source="/ModernWpf;component/DesignTime/DesignTimeResources.xaml" />
<ui:ThemeResources />
<ui:XamlControlsResources />
</ResourceDictionary.MergedDictionaries>

View File

@ -0,0 +1,7 @@
namespace ModernWpfPlayground
{
public class IntellisenseResourceDictionary : ModernWpf.DesignTime.IntellisenseResourcesBase
{
}
}

View File

@ -1,7 +0,0 @@
namespace ModernWpfPlayground
{
public class IntellisenseResources : ModernWpf.DesignTime.IntellisenseResourcesBase
{
}
}

View File

@ -8,10 +8,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ModernWpfUI" Version="0.8.1" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>

View File

@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Windows;
using Microsoft.Win32;
namespace ModernWpfPlayground.MvvmStuff
{
@ -13,7 +9,7 @@ namespace ModernWpfPlayground.MvvmStuff
{
private readonly Dictionary<string, object> _values = new Dictionary<string, object>();
public IReadOnlyDictionary<string, object> Values => _values;
protected IReadOnlyDictionary<string, object> Values => _values;
protected bool SetProperty<T>(T value, Action<T>? onChanged = null,
[CallerMemberName] string? propertyName = null)
@ -35,8 +31,6 @@ namespace ModernWpfPlayground.MvvmStuff
public event PropertyChangedEventHandler? PropertyChanged;
[NotifyPropertyChangedInvocator]
[PublicAPI]
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));

View File

@ -22,15 +22,16 @@ namespace ModernWpfPlayground.PropertyPresenter2
/// <summary>
/// Returns the content of a description attribute of an enum.
/// </summary>
/// <param name="enumValue"></param>
/// <param name="value"></param>
/// <returns></returns>
private static string GetDescription(object enumValue)
private static string GetDescription(object value)
{
if (!(value is Enum enumValue)) return string.Empty;
var descriptionAttribute = enumValue.GetType()
.GetField(enumValue.ToString()).GetCustomAttributes(false)
.OfType<DescriptionAttribute>().FirstOrDefault();
return descriptionAttribute?.Description ?? enumValue.ToString();
return descriptionAttribute?.Description ?? value.ToString();
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View File

@ -12,20 +12,20 @@ namespace ModernWpfPlayground.PropertyPresenter2
/// <summary>
/// Default data template. (currently Textbox)
/// </summary>
public DataTemplate DefaultDataTemplate { private get; set; }
public DataTemplate? DefaultDataTemplate { private get; set; }
/// <summary>
/// Data template for boolean. (currently Checkbox)
/// </summary>
public DataTemplate BooleanDataTemplate { private get; set; }
public DataTemplate? BooleanDataTemplate { private get; set; }
/// <summary>
/// Data template for enums. (currently Combobox)
/// </summary>
public DataTemplate EnumComboBoxDataTemplate { private get; set; }
public DataTemplate? EnumComboBoxDataTemplate { private get; set; }
/// <inheritdoc />
public override DataTemplate SelectTemplate(object item, DependencyObject container)
public override DataTemplate? SelectTemplate(object item, DependencyObject container)
{
return item switch
{