Skip to content

Commit 8c2ccf3

Browse files
committed
Changes from review
1 parent f3652ba commit 8c2ccf3

File tree

13 files changed

+458
-575
lines changed

13 files changed

+458
-575
lines changed

src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/MultiSelectionComboBoxExample.xaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
1-
<!--
2-
Licensed to the .NET Foundation under one or more agreements.
3-
The .NET Foundation licenses this file to you under the MIT license.
4-
See the LICENSE file in the project root for more information.
5-
-->
6-
7-
<UserControl x:Class="MetroDemo.ExampleViews.MultiSelectionComboBoxExample"
1+
<UserControl x:Class="MetroDemo.ExampleViews.MultiSelectionComboBoxExample"
82
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
93
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
104
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
115
xmlns:local="clr-namespace:MetroDemo"
12-
xmlns:local1="clr-namespace:MetroDemo.ExampleViews"
136
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
147
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
158
xmlns:system="clr-namespace:System;assembly=mscorlib"
169
d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
1710
d:DesignHeight="450"
1811
d:DesignWidth="800"
1912
mc:Ignorable="d">
13+
2014
<UserControl.Resources>
2115
<Style BasedOn="{StaticResource MahApps.Styles.MetroHeader.Horizontal}" TargetType="mah:MetroHeader" />
2216
<Style BasedOn="{StaticResource MahApps.Styles.GroupBox}" TargetType="GroupBox">
23-
<Setter Property="Margin" Value="5,5,5,0" />
17+
<Setter Property="Margin" Value="5 5 5 0" />
2418
</Style>
2519

2620
<!-- Selection Order -->
27-
<ObjectDataProvider x:Key="Demo.Enums.OrderSelectedItemsBy"
21+
<ObjectDataProvider x:Key="Demo.Enums.SelectedItemsOrderType"
2822
MethodName="GetValues"
29-
ObjectType="{x:Type system:Enum}">
23+
ObjectType="{x:Type mah:SelectedItemsOrderType}">
3024
<ObjectDataProvider.MethodParameters>
31-
<x:Type TypeName="mah:OrderSelectedItemsBy" />
25+
<x:Type TypeName="mah:SelectedItemsOrderType" />
3226
</ObjectDataProvider.MethodParameters>
3327
</ObjectDataProvider>
3428

@@ -146,7 +140,7 @@
146140
<ComboBox ItemsSource="{Binding Source={StaticResource Demo.Enums.SelectionMode}}" SelectedItem="{Binding ElementName=mscb_Example, Path=SelectionMode}" />
147141
</mah:MetroHeader>
148142
<mah:MetroHeader Header="OrderSelectedItemsBy">
149-
<ComboBox ItemsSource="{Binding Source={StaticResource Demo.Enums.OrderSelectedItemsBy}}" SelectedItem="{Binding ElementName=mscb_Example, Path=OrderSelectedItemsBy}" />
143+
<ComboBox ItemsSource="{Binding Source={StaticResource Demo.Enums.SelectedItemsOrderType}}" SelectedItem="{Binding ElementName=mscb_Example, Path=OrderSelectedItemsBy}" />
150144
</mah:MetroHeader>
151145
<mah:MetroHeader Header="ObjectToStringComparer">
152146
<ComboBox SelectedValue="{Binding ElementName=mscb_Example, Path=ObjectToStringComparer}" SelectedValuePath="Tag">

src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindowViewModel.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,8 @@ public void Dispose()
239239

240240
public int SelectedIndex { get; set; }
241241

242-
243242
public ICollection<Album> Albums { get; set; }
244243

245-
246-
private Album _MultiSelectionComboBoxSelectedAlbum;
247-
[Display(Prompt = "Select an Album")]
248-
public Album MultiSelectionComboBoxSelectedAlbum
249-
{
250-
get { return _MultiSelectionComboBoxSelectedAlbum; }
251-
set { _MultiSelectionComboBoxSelectedAlbum = value; OnPropertyChanged(nameof(MultiSelectionComboBoxSelectedAlbum)); }
252-
}
253-
254-
255244
public List<Artist> Artists { get; set; }
256245

257246
private ObservableCollection<Artist> _selectedArtists = new ObservableCollection<Artist>();
@@ -682,8 +671,14 @@ private void ToggleIconScaling(object obj)
682671
"Zebra"
683672
};
684673

685-
[Display(Prompt = "Select your favoite animal(s)")]
686-
public string MyFavoriteAnimal { get; set; }
674+
private object myFavoriteAnimal;
675+
676+
[Display(Prompt = "Select your favorite animal(s)")]
677+
public object MyFavoriteAnimal
678+
{
679+
get => this.myFavoriteAnimal;
680+
set => this.Set(ref this.myFavoriteAnimal, value);
681+
}
687682

688683
public ObjectParser MyObjectParser {get;}
689684
}

src/MahApps.Metro.Samples/MahApps.Metro.Demo/Models/Album.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Collections.Generic;
77
using System.ComponentModel;
8-
using System.Globalization;
98
using System.Linq;
109
using MetroDemo.Core;
1110

src/MahApps.Metro.Samples/MahApps.Metro.Demo/Models/ObjectParser.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55
using MahApps.Metro.Controls;
66
using MahApps.Metro.Controls.Dialogs;
7-
using System;
8-
using System.Collections.Generic;
97
using System.Globalization;
10-
using System.Linq;
11-
using System.Text;
12-
using System.Threading.Tasks;
13-
using System.Windows;
148

159
namespace MetroDemo.Models
1610
{
@@ -39,7 +33,7 @@ public object CreateObjectFromString(string input, CultureInfo culture, string s
3933
DefaultButtonFocus = MessageDialogResult.Affirmative
4034
};
4135

42-
if (_dialogCoordinator.ShowModalMessageExternal(_mainWindowViewModel, "Add Animal", $"Do you want to add \"{input}\" to the animals list?", MessageDialogStyle.AffirmativeAndNegative, dialogSettings) == MessageDialogResult.Affirmative)
36+
if (this._dialogCoordinator.ShowModalMessageExternal(this._mainWindowViewModel, "Add Animal", $"Do you want to add \"{input}\" to the animals list?", MessageDialogStyle.AffirmativeAndNegative, dialogSettings) == MessageDialogResult.Affirmative)
4337
{
4438
return input.Trim();
4539
}

src/MahApps.Metro/Controls/Helper/BindingHelper.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ public static class BindingHelper
1616
/// <summary>
1717
/// A dummy property to initialize the binding to evaluate
1818
/// </summary>
19-
private static readonly DependencyProperty DummyProperty = DependencyProperty.RegisterAttached(
20-
"Dummy",
21-
typeof(object),
22-
typeof(BindingHelper),
23-
new UIPropertyMetadata(null));
19+
private static readonly DependencyProperty DummyProperty
20+
= DependencyProperty.RegisterAttached("Dummy",
21+
typeof(object),
22+
typeof(BindingHelper),
23+
new UIPropertyMetadata(null));
2424

2525
/// <summary>
2626
/// A dummy property to initialize the binding to evaluate. This property supports also string format.
2727
/// </summary>
28-
private static readonly DependencyProperty DummyTextProperty = DependencyProperty.RegisterAttached(
29-
"DummyText",
30-
typeof(string),
31-
typeof(BindingHelper),
32-
new UIPropertyMetadata(null));
28+
private static readonly DependencyProperty DummyTextProperty
29+
= DependencyProperty.RegisterAttached("DummyText",
30+
typeof(string),
31+
typeof(BindingHelper),
32+
new UIPropertyMetadata(null));
3333

3434
/// <summary>
3535
/// Evaluates a defined <see cref="Binding"/>-path on the given object
@@ -48,7 +48,7 @@ public static object Eval(object source, string expression)
4848
/// </summary>
4949
/// <param name="source">the object to evaluate</param>
5050
/// <param name="expression">the binding expression to evaluate</param>
51-
/// <param name="format">the stringformat to use</param>
51+
/// <param name="format">the string format to use</param>
5252
/// <returns>the result of the <see cref="Binding"/></returns>
5353
public static object Eval(object source, string expression, string format)
5454
{
@@ -70,29 +70,29 @@ public static object Eval(Binding binding, object source)
7070
}
7171

7272
Binding newBinding = new Binding
73-
{
74-
Source = source,
75-
AsyncState = binding.AsyncState,
76-
BindingGroupName = binding.BindingGroupName,
77-
BindsDirectlyToSource = binding.BindsDirectlyToSource,
78-
Path = binding.Path,
79-
Converter = binding.Converter,
80-
ConverterCulture = binding.ConverterCulture,
81-
ConverterParameter = binding.ConverterParameter,
82-
FallbackValue = binding.FallbackValue,
83-
IsAsync = binding.IsAsync,
84-
Mode = BindingMode.OneWay,
85-
StringFormat = binding.StringFormat,
86-
TargetNullValue = binding.TargetNullValue
87-
};
73+
{
74+
Source = source,
75+
AsyncState = binding.AsyncState,
76+
BindingGroupName = binding.BindingGroupName,
77+
BindsDirectlyToSource = binding.BindsDirectlyToSource,
78+
Path = binding.Path,
79+
Converter = binding.Converter,
80+
ConverterCulture = binding.ConverterCulture,
81+
ConverterParameter = binding.ConverterParameter,
82+
FallbackValue = binding.FallbackValue,
83+
IsAsync = binding.IsAsync,
84+
Mode = BindingMode.OneWay,
85+
StringFormat = binding.StringFormat,
86+
TargetNullValue = binding.TargetNullValue
87+
};
8888
return Eval(newBinding);
8989
}
9090

9191
/// <summary>
9292
/// Evaluates a defined <see cref="Binding"/> on the given <see cref="DependencyObject"/>
9393
/// </summary>
9494
/// <param name="binding">The <see cref="Binding"/> to evaluate</param>
95-
/// <param name="dependencyObject">optional: The <see cref="DependencyObject"/> to evalutate</param>
95+
/// <param name="dependencyObject">optional: The <see cref="DependencyObject"/> to evaluate</param>
9696
/// <returns>The resulting object</returns>
9797
public static object Eval(Binding binding, DependencyObject dependencyObject)
9898
{
@@ -120,4 +120,4 @@ public static object Eval(Binding binding)
120120
return Eval(binding, null);
121121
}
122122
}
123-
}
123+
}

src/MahApps.Metro/Controls/MultiSelectionComboBox/ICompareObjectToString.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@ public interface ICompareObjectToString
1919
/// <param name="input">The string to compare</param>
2020
/// <param name="objectToCompare">The object to compare</param>
2121
/// <param name="stringComparison">The <see cref="StringComparison"/> used to check if the string matches</param>
22-
/// <param name="stringFormat">The string format to applay</param>
23-
/// <returns>true if the string represents the object, otherwise fase.</returns>
22+
/// <param name="stringFormat">The string format to apply</param>
23+
/// <returns>true if the string represents the object, otherwise false.</returns>
2424
public bool CheckIfStringMatchesObject(string input, object objectToCompare, StringComparison stringComparison, string stringFormat);
2525
}
2626

27-
2827
[MarkupExtensionReturnType(typeof(DefaultObjectToStringComparer))]
2928
public class DefaultObjectToStringComparer : MarkupExtension, ICompareObjectToString
3029
{
31-
private static DefaultObjectToStringComparer _Instance;
32-
3330
/// <inheritdoc/>
3431
public bool CheckIfStringMatchesObject(string input, object objectToCompare, StringComparison stringComparison, string stringFormat)
3532
{
@@ -63,7 +60,7 @@ public bool CheckIfStringMatchesObject(string input, object objectToCompare, Str
6360
/// <inheritdoc/>
6461
public override object ProvideValue(IServiceProvider serviceProvider)
6562
{
66-
return _Instance ??= new DefaultObjectToStringComparer();
63+
return this;
6764
}
6865
}
69-
}
66+
}

src/MahApps.Metro/Controls/MultiSelectionComboBox/IParseStringToObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public interface IParseStringToObject
1616
/// </summary>
1717
/// <param name="input">The input string to parse</param>
1818
/// <param name="culture">The culture which should be used to parse</param>
19-
/// <param name="stringFormat">The string format to applay</param>
19+
/// <param name="stringFormat">The string format to apply</param>
2020
/// <returns>The object if successful, otherwise null</returns>
2121
object CreateObjectFromString(string input, CultureInfo culture, string stringFormat);
2222
}
23-
}
23+
}

0 commit comments

Comments
 (0)