Rob Perkins
Rob Perkins

Reputation: 3130

Setting and Retrieving the x:Name attribute for a XAML object

Consider this WPF3D XAML snippet, bearing in mind that the object declared does not inherit FrameworkElement:

<Visual3D x:Name="SomeName" />

How, in code, would one go about retrieving the string specified for the value of x:Name? Yes, it's declared as a symbol for code-behind access at build time, but if you're transforming a logical tree with a non-FrameworkElement root into a different format, there's no FrameworkElement.NameProperty.GetValue() defined.

Upvotes: 2

Views: 277

Answers (2)

Rob Perkins
Rob Perkins

Reputation: 3130

There appears to be no direct way to do this.

Upvotes: 1

Benoit Catherinet
Benoit Catherinet

Reputation: 3345

You could create a class which inherit from the Visual 3D class and add the RuntimeNameProperty attribute on the class as well as a property which will be used to save the name.

Upvotes: 1

Related Questions