0

I am generating some Xaml based on some other source of input. In some cases I am generating x:Name values but they have invalid characters. I found this article on MSDN:

XamlName Grammar

Which describes the grammar of a x:Name tag but doesn't tell me how to actually apply this. Clearly there is some code to validate this name at runtime but what is the easiest way to actually fix up a string with invalid characters?

justin.m.chase
  • 13,061
  • 8
  • 52
  • 100
  • Generating a valid name surely is the easiest way. Trying to fix one that's busted seems pointless and just another source of more problems. – Hans Passant May 18 '10 at 18:28
  • Yes, why generate invalid names in the first place? – alexander.biskop May 18 '10 at 20:17
  • Basically we were taking a file which had user input in it, and using some data from it to generate xaml. The input was varied and I wanted a way to validate / scrub the input into valid x:Name values. There doesn't appear to be an easy way to do. – justin.m.chase Feb 12 '14 at 15:38

1 Answers1

1

Turns out it made the most sense to just drop all of the x:Names and not generate them. We don't really need to dig around inside for particular elements afterall. We still have to generate file names and Class names but that's a bit easier of a problem I think.

justin.m.chase
  • 13,061
  • 8
  • 52
  • 100