I’ve created a TabItem control with a particular structure(of DataGrids Buttons etc.). Some of the controls in the TabItem have names.This entire setup is created in the code-behind. Whenever a new tab is created, I clone this TabItem. The problem is that the names of the controls are registered with the namescope and when I clone these controls they cannot be re-registered.
I’m not sure what my options are here, but
-
Can I create a new namescope for each
TabItem? Is that advisable? If so how can I find a particular namescope? -
Can I register the control names with the parent control and not worry about changing namescopes?
What is my solution here?
Any help is appreciated
Without knowing a bit more about what you are doing, it is hard to advise, but here are some thoughts …
What are you using these names for? Could you use some other properties of your control instead, e.g. Tag?
Creating controls then cloning them sounds a bit nasty! Why not create a user control which contains all your controls? You can still create them in code-behind in the user control. This will solve your namescope issue, and also provide better structuring of your code!