WPF Tip: Names can’t have ":" in them…

If you are doing storyboard-based animation, the animation is hooked up to a specific element through a unique id. You write code something like this:

element.Name = "Fred";
window.RegisterName(element.Name, element);

The second call establishes the relationship between the name and the object.

If you're writing cod where there are multiple elements, you need to create unique names. So, something like:

element.Name = "Fred_" + m_id.ToString();

works great. However, if you use:

element.Name = "Fred:" + m_id.ToString();

You'll get a not-very-helpful exception...

Comments (2)

  1. Sheva says:

    Actually the naming convention for the Name attribute is coherent with the C#’s  naming convention for variables.


Skip to main content