-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-3839) Allow setting AutomationProperties for HamburgerMenuItem
Allow setting the AutomationProperties for HamburgerMenuItem - AutomationProperties.HelpText - AutomationProperties.LabeledBy - AutomationProperties.Name If Name or HelpText are empty the Label and ToolTip properties will be used.
- Loading branch information
Showing
3 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/MahApps.Metro/Converters/HamburgerMenuItemAccessibleConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
|
||
namespace MahApps.Metro.Converters | ||
{ | ||
[ValueConversion(typeof(object), typeof(object))] | ||
[MarkupExtensionReturnType(typeof(HamburgerMenuItemAccessibleConverter))] | ||
public class HamburgerMenuItemAccessibleConverter : MarkupMultiConverter | ||
{ | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is null) | ||
{ | ||
return Binding.DoNothing; | ||
} | ||
|
||
return value; | ||
} | ||
|
||
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return Binding.DoNothing; | ||
} | ||
|
||
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (values is null) | ||
{ | ||
return Binding.DoNothing; | ||
} | ||
|
||
var automationPropertiesValue = values.ElementAtOrDefault(1) as string; | ||
if (!string.IsNullOrEmpty(automationPropertiesValue)) | ||
{ | ||
return automationPropertiesValue; | ||
} | ||
|
||
return this.Convert(values.ElementAtOrDefault(0), targetType, parameter, culture); | ||
} | ||
|
||
public override object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) | ||
{ | ||
return targetTypes.Select(t => Binding.DoNothing).ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters