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

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

SBOMs are essential to circumventing software supply chain attacks, and they provide visibility into various software components.

Related

  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • Implement Hibernate Second-Level Cache With NCache
  • Modify JSON Data in Postgres and Hibernate 6
  • Top 10 C# Keywords and Features

Trending

  • Advanced Insight Generation: Revolutionizing Data Ingestion for AI-Powered Search
  • MCP and The Spin-Off CoT Pattern: How AI Agents Really Use Tools
  • Self-Supervised Learning Techniques
  • How to Reduce Technical Debt With Artificial Intelligence (AI)

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.3K 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, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • Implement Hibernate Second-Level Cache With NCache
  • Modify JSON Data in Postgres and Hibernate 6
  • Top 10 C# Keywords and Features

Partner Resources

×

Comments

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: