Browse Source
src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\XamlProperty.cs Original author: Tobias Gummesson ------------------------------------------------------------------------------------------------------------------------ The previous solution regarding XAML names expected all properties of type string named Name to represent a name in XAML namescope, and this caused trouble with types with a property named Name that did not represent a XAML name. In this case the value of the property tried to be registered as name to the namescope and this caused either the value to be occupied as name, or threw an exception if name already was taken or the value consisted of characters forbidden in XAML names causing the value to not be set at all. To solve this the value of a Name property is only registered to namescope if the property represents a XAML name (defined by RuntimeNamePropertyAttribute). Also added a Name property to XamlObject that always sets the name to x:Name attribute, but gets it from either x:Name or the property that represents the XAML name if it exists (both are valid places for name registration). Fixed a bug in XamlParser where x:Name value was not registered in its namescope. All other changes (for example changes in PropertyGrid/XamlDesignItem) was to support the Name fixes described above.pull/53/merge
7 changed files with 730 additions and 590 deletions
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.Windows; |
||||
using System.Windows.Markup; |
||||
|
||||
namespace ICSharpCode.WpfDesign.XamlDom |
||||
{ |
||||
/// <summary>
|
||||
/// Static methods to help with <see cref="System.Windows.Markup.INameScope"/> operations on Xaml elements.
|
||||
/// </summary>
|
||||
internal static class NameScopeHelper |
||||
{ |
||||
/// <summary>
|
||||
/// Finds the XAML namescope for the specified object and uses it to unregister the old name and then register the new name.
|
||||
/// </summary>
|
||||
/// <param name="namedObject">The object where the name was changed.</param>
|
||||
/// <param name="oldName">The old name.</param>
|
||||
/// <param name="newName">The new name.</param>
|
||||
public static void NameChanged(XamlObject namedObject, string oldName, string newName) |
||||
{ |
||||
var obj = namedObject; |
||||
while (obj != null) { |
||||
var nameScope = obj.Instance as INameScope; |
||||
if (nameScope == null) { |
||||
var depObj = obj.Instance as DependencyObject; |
||||
if (depObj != null) |
||||
nameScope = NameScope.GetNameScope(depObj); |
||||
} |
||||
if (nameScope != null) { |
||||
if (oldName != null) { |
||||
try { |
||||
nameScope.UnregisterName(oldName); |
||||
} catch (Exception x) { |
||||
Debug.WriteLine(x.Message); |
||||
} |
||||
} |
||||
if (newName != null) { |
||||
nameScope.RegisterName(newName, namedObject.Instance); |
||||
} |
||||
break; |
||||
} |
||||
obj = obj.ParentObject; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -1,91 +1,92 @@
@@ -1,91 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.WpfDesign.XamlDom</RootNamespace> |
||||
<AssemblyName>ICSharpCode.WpfDesign.XamlDom</AssemblyName> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<SignAssembly>True</SignAssembly> |
||||
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile> |
||||
<DelaySign>False</DelaySign> |
||||
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> |
||||
<RunCodeAnalysis>False</RunCodeAnalysis> |
||||
<CodeAnalysisRules>-Microsoft.Globalization#CA1303;-Microsoft.Performance#CA1800</CodeAnalysisRules> |
||||
<OutputPath>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\</OutputPath> |
||||
<DocumentationFile>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> |
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<Optimize>False</Optimize> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="PresentationCore"> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="PresentationFramework"> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xaml" /> |
||||
<Reference Include="WindowsBase"> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
<Compile Include="CollectionElementsCollection.cs" /> |
||||
<Compile Include="CollectionSupport.cs" /> |
||||
<Compile Include="IXamlErrorSink.cs" /> |
||||
<Compile Include="MarkupExtensionParser.cs" /> |
||||
<Compile Include="MarkupExtensionPrinter.cs" /> |
||||
<Compile Include="PositionXmlDocument.cs" /> |
||||
<Compile Include="XamlConstants.cs" /> |
||||
<Compile Include="XamlDocument.cs" /> |
||||
<Compile Include="XamlLoadException.cs" /> |
||||
<Compile Include="XamlObject.cs" /> |
||||
<Compile Include="XamlObjectServiceProvider.cs" /> |
||||
<Compile Include="XamlParser.cs" /> |
||||
<Compile Include="XamlParserSettings.cs" /> |
||||
<Compile Include="XamlProperty.cs" /> |
||||
<Compile Include="XamlPropertyInfo.cs" /> |
||||
<Compile Include="XamlPropertyValue.cs" /> |
||||
<Compile Include="XamlStaticTools.cs" /> |
||||
<Compile Include="XamlTextValue.cs" /> |
||||
<Compile Include="XamlTypeFinder.cs" /> |
||||
<Compile Include="XamlTypeResolverProvider.cs" /> |
||||
</ItemGroup> |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.WpfDesign.XamlDom</RootNamespace> |
||||
<AssemblyName>ICSharpCode.WpfDesign.XamlDom</AssemblyName> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<SignAssembly>True</SignAssembly> |
||||
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile> |
||||
<DelaySign>False</DelaySign> |
||||
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> |
||||
<RunCodeAnalysis>False</RunCodeAnalysis> |
||||
<CodeAnalysisRules>-Microsoft.Globalization#CA1303;-Microsoft.Performance#CA1800</CodeAnalysisRules> |
||||
<OutputPath>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\</OutputPath> |
||||
<DocumentationFile>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> |
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<Optimize>False</Optimize> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="PresentationCore"> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="PresentationFramework"> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xaml" /> |
||||
<Reference Include="WindowsBase"> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
<Compile Include="CollectionElementsCollection.cs" /> |
||||
<Compile Include="CollectionSupport.cs" /> |
||||
<Compile Include="IXamlErrorSink.cs" /> |
||||
<Compile Include="MarkupExtensionParser.cs" /> |
||||
<Compile Include="MarkupExtensionPrinter.cs" /> |
||||
<Compile Include="NameScopeHelper.cs" /> |
||||
<Compile Include="PositionXmlDocument.cs" /> |
||||
<Compile Include="XamlConstants.cs" /> |
||||
<Compile Include="XamlDocument.cs" /> |
||||
<Compile Include="XamlLoadException.cs" /> |
||||
<Compile Include="XamlObject.cs" /> |
||||
<Compile Include="XamlObjectServiceProvider.cs" /> |
||||
<Compile Include="XamlParser.cs" /> |
||||
<Compile Include="XamlParserSettings.cs" /> |
||||
<Compile Include="XamlProperty.cs" /> |
||||
<Compile Include="XamlPropertyInfo.cs" /> |
||||
<Compile Include="XamlPropertyValue.cs" /> |
||||
<Compile Include="XamlStaticTools.cs" /> |
||||
<Compile Include="XamlTextValue.cs" /> |
||||
<Compile Include="XamlTypeFinder.cs" /> |
||||
<Compile Include="XamlTypeResolverProvider.cs" /> |
||||
</ItemGroup> |
||||
</Project> |
||||
Loading…
Reference in new issue