DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Security Is a Platform Property, Not a Pipeline Step
  • An XGBoost Property Valuation Postmortem: Leakage, Overfitting, and SHAP Surprises
  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • Implement Hibernate Second-Level Cache With NCache

Trending

  • A Walk-Through of the DZone Article Editor
  • Jeffrey Microscope for Generating Flame Graphs in Java
  • The Dark Side of Big Data: Pseudo-Science & Fooled By Randomness
  • Top 30 Eclipse Keyboard Shortcuts for Java Programmers

Not able to bind to Uid or Name property in XAML

By 
Merrick Chaffer user avatar
Merrick Chaffer
·
Feb. 24, 11 · News
Likes (0)
Comment
Save
Tweet
Share
6.6K Views

Join the DZone community and get the full member experience.

Join For Free
Even though x:Name is a dependency property for a WPF framework element, you cannot the name of the control to a static resource in the code behind file.

<Window x:Class="WpfApplication2.Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:local="clr-namespace:WpfApplication2"

Title="Window1"

Height="300"

Width="300">

<Grid>

<Grid.CommandBindings>

<CommandBinding Command="local:AppCommands.Find"

CanExecute="CanFind"

Executed="CommandBinding_OnExecuted"/>

</Grid.CommandBindings>

<StackPanel>

<TextBox Name="textBox1"/>

<Button Command="local:AppCommands.Find"

Name="{x:Static local:Window1.MyControlName}"/>

</StackPanel>

</Grid>

</Window>



…



namespace WpfApplication2

{

/// <summary>

/// Interaction logic for Window1.xaml

/// </summary>

public partial class Window1 : Window

{



public static readonly string MyControlName = "name";

Gives this compilation error

c:\Dev\.NET\WpfApplication2\WpfApplication2\Window1.xaml(17,21): error MC3079: MarkupExtensions are not allowed for Uid or Name property values, so '{x:Static local:Window1.MyControlName}' is not valid. Line 17 Position 21.




Property (programming)

Published at DZone with permission of Merrick Chaffer. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Security Is a Platform Property, Not a Pipeline Step
  • An XGBoost Property Valuation Postmortem: Leakage, Overfitting, and SHAP Surprises
  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • Implement Hibernate Second-Level Cache With NCache

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook