Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed support for dots in resource names #700

Merged
merged 1 commit into from
Mar 19, 2019
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
1 change: 1 addition & 0 deletions doc/ReleaseNotes/_ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* `KeyUp` event properly sends `KeyEventArgs` to the controls
* Add ItemsSource CollectionViewSource update support (#697)
* Add support for the `CollectionViewSource.ItemsPath` property
* Fixed support for dots in resource names (#700)

### Breaking changes
* Make `UIElement.IsPointerPressed` and `IsPointerOver` internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,17 @@ private void BuildBackingFields(IIndentedStringBuilder writer)
}
}

private static string SanitizeResourceName(string name) => name.Replace("-", "_");
private static readonly char[] ResourceInvalidCharacters = new[] { '.', '-' };

private static string SanitizeResourceName(string name)
{
foreach (var c in ResourceInvalidCharacters)
{
name = name.Replace(c, '_');
}

return name;
}

private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel = false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@
<Setter Property="Background" Value="Blue" />
</Style>

<Style x:Key="Resource-with-dashes" TargetType="Grid"
<Style x:Key="Resource-with-dashes" TargetType="Grid"
BasedOn="{StaticResource baseGridStyle}">
<Setter Property="Background" Value="Blue" />
</Style>
<Setter Property="Background" Value="Blue" />
</Style>

<Style x:Key="Resource.with.dots" TargetType="Grid"
BasedOn="{StaticResource baseGridStyle}">
<Setter Property="Background" Value="Blue" />
</Style>

<x:Double x:Key="Double-Resource-With-Dashes">42</x:Double>

Expand Down