Skip to content

Commit a6b6e44

Browse files
committed
x:name does not set the name property of a Control.
Now also Code like this: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Canvas> <Button x:Name="aa" Content="{Binding Name, ElementName=aa}" Width="75.2" Height="23.2" Canvas.Left="85.6" Canvas.Top="197.6" /> </Canvas> </Window> works!
1 parent 9cf2257 commit a6b6e44

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/NameScopeHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public static void NameChanged(XamlObject namedObject, string oldName, string ne
3838
}
3939
if (newName != null) {
4040
nameScope.RegisterName(newName, namedObject.Instance);
41+
42+
try{
43+
var prp = namedObject.ElementType.GetProperty(namedObject.RuntimeNameProperty);
44+
if (prp != null)
45+
prp.SetValue(namedObject.Instance, newName, null);
46+
} catch (Exception x) {
47+
Debug.WriteLine(x.Message);
48+
}
4149
}
4250
break;
4351
}

0 commit comments

Comments
 (0)