Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Globalization;
using System.Windows.Data;

namespace MaterialDesignThemes.Wpf.Converters.Internal;

public class AutomationPropertiesNameConverter : IValueConverter
{
public static readonly AutomationPropertiesNameConverter Instance = new();

public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is string stringValue)
{
return stringValue;
}
return string.Empty;
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<converters:OutlinedStyleActiveBorderMarginCompensationConverter x:Key="OutlinedStyleActiveBorderMarginCompensationConverter" />
<converters:ElevationRadiusConverter x:Key="ElevationRadiusConverter" Multiplier="-1" />
</Style.Resources>
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="DropDownBackground" Value="{DynamicResource MaterialDesign.Brush.Card.Background}" />
<Setter Property="DropDownElevation" Value="Dp2" />
<Setter Property="Template">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@
</ControlTemplate>

<Style x:Key="MaterialDesignComboBox" TargetType="{x:Type ComboBox}">
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.ComboBox.Border}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
xmlns:convertersInternal="clr-namespace:MaterialDesignThemes.Wpf.Converters.Internal"
xmlns:internal="clr-namespace:MaterialDesignThemes.Wpf.Internal"
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
<ResourceDictionary.MergedDictionaries>
Expand All @@ -19,7 +20,7 @@
<Style.Resources>
<Style x:Key="NestedTextBoxStyle" TargetType="{x:Type DatePickerTextBox}" BasedOn="{StaticResource MaterialDesignTextBox}" />
</Style.Resources>
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.ForegroundLight}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="CalendarStyle" Value="{StaticResource MaterialDesignDatePickerCalendarPortrait}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
xmlns:convertersInternal="clr-namespace:MaterialDesignThemes.Wpf.Converters.Internal"
xmlns:internal="clr-namespace:MaterialDesignThemes.Wpf.Internal"
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
<ResourceDictionary.MergedDictionaries>
Expand Down Expand Up @@ -33,7 +34,7 @@
TargetType="{x:Type ButtonBase}"
BasedOn="{StaticResource MaterialDesignNumericUpDownButtonsStyle}" />
</Style.Resources>
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.ForegroundLight}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="DecreaseContent" Value="{StaticResource ContentDecrease}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</Style>
</Style.Resources>
<Setter Property="AllowDrop" Value="true" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.ForegroundLight}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
Expand Down Expand Up @@ -609,7 +609,7 @@
</Style>
</Style.Resources>
<Setter Property="AllowDrop" Value="true" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.ForegroundLight}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<convertersInternal:TextBoxHorizontalScrollBarWidthConverter x:Key="TextBoxHorizontalScrollBarWidthConverter" />
</Style.Resources>

<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="AllowDrop" Value="true" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.TextBox.Border}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
xmlns:convertersInternal="clr-namespace:MaterialDesignThemes.Wpf.Converters.Internal"
xmlns:internal="clr-namespace:MaterialDesignThemes.Wpf.Internal"
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
<ResourceDictionary.MergedDictionaries>
Expand All @@ -11,7 +12,7 @@
<Style.Resources>
<Style x:Key="NestedTextBoxStyle" TargetType="wpf:TimePickerTextBox" BasedOn="{StaticResource MaterialDesignTextBox}" />
</Style.Resources>
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource Self}, Converter={x:Static convertersInternal:AutomationPropertiesNameConverter.Instance}}" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.ForegroundLight}" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="ClockHostContentControlStyle">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Globalization;
using MaterialDesignThemes.Wpf.Converters.Internal;
using TUnit.Core;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
using System.Threading.Tasks;

namespace MaterialDesignThemes.Wpf.Tests.Converters;

public sealed class AutomationPropertiesNameConverterTests
{
[Test]
public async Task Convert_StringValue_ReturnsOriginalString()
{
var converter = AutomationPropertiesNameConverter.Instance;
string input = "Test String";

var result = converter.Convert(input, typeof(string), null, CultureInfo.InvariantCulture);

await Assert.That(result).IsEqualTo(input);
}

[Test]
public async Task Convert_NullValue_ReturnsEmptyString()
{
var converter = AutomationPropertiesNameConverter.Instance;

var result = converter.Convert(null, typeof(string), null, CultureInfo.InvariantCulture);

await Assert.That(result).IsEqualTo(string.Empty);
}

[Test]
public async Task Convert_NonStringValue_ReturnsEmptyString()
{
var converter = AutomationPropertiesNameConverter.Instance;
int input = 42;

var result = converter.Convert(input, typeof(string), null, CultureInfo.InvariantCulture);

await Assert.That(result).IsEqualTo(string.Empty);
}

[Test]
public async Task Convert_EmptyString_ReturnsEmptyString()
{
var converter = AutomationPropertiesNameConverter.Instance;
string input = string.Empty;

var result = converter.Convert(input, typeof(string), null, CultureInfo.InvariantCulture);

await Assert.That(result).IsEqualTo(string.Empty);
}
}
Loading