Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from keith-hsv/master
Bug Fix - Fixes #3
- Loading branch information
Showing
7 changed files
with
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Xml.Linq; | ||
|
||
namespace XamlMagic.Service.Helpers | ||
{ | ||
internal static class AttributeHelper | ||
{ | ||
/// <summary> | ||
/// Gets a properly configured XName object from an XAttribute. | ||
/// </summary> | ||
/// <param name="attribute"></param> | ||
/// <returns></returns> | ||
public static XName GetName(XAttribute attribute) | ||
{ | ||
if(attribute.Value.Contains(":")) | ||
{ | ||
string[] parts = attribute.Value.Split(':'); | ||
|
||
if (parts.Length == 2) | ||
{ | ||
string prefix = parts[0]; | ||
string value = parts[1]; | ||
|
||
var namespaceOfPrefix = attribute.Parent.GetNamespaceOfPrefix(prefix); | ||
|
||
return XName.Get(value, namespaceOfPrefix.NamespaceName); | ||
} | ||
} | ||
|
||
return XName.Get(attribute.Value); | ||
} | ||
} | ||
} |
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
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
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,8 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:XamlMagic"> | ||
<Style x:Key="ToggleButtonStyle" TargetType="ToggleButton"> | ||
<Setter Property="local:AttachedProperties.MyProperty" Value="Red" /> | ||
<Setter Property="BorderThickness" Value="1" /> | ||
</Style> | ||
</ResourceDictionary> |
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,6 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:XamlMagic"> | ||
<Style x:Key="ToggleButtonStyle" TargetType="ToggleButton"> | ||
<Setter Property="local:AttachedProperties.MyProperty" Value="Red"/> | ||
<Setter Property="BorderThickness" Value="1"/> | ||
</Style> | ||
</ResourceDictionary> |
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,17 @@ | ||
using NUnit.Framework; | ||
using XamlMagic.Service.Options; | ||
|
||
namespace XamlMagic.UnitTests | ||
{ | ||
[TestFixture] | ||
public sealed partial class UnitTests | ||
{ | ||
[Test] | ||
public void TestAttachedProperty() | ||
{ | ||
var stylerOptions = new StylerOptions(config: this.legacyConfig); | ||
|
||
this.DoTest(stylerOptions); | ||
} | ||
} | ||
} |
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