Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In the specific task, I have TabControl and Tab Item defined has below
<TabControl> Header = "Tabs1" TabStripPlacement="Top"...
<Tab Item> Name= "MyTab1" Color="Red" />
<Label Name = "abc" ...........>
<TextBox Name = "xyz" >
</TabItem>
<Tab Item> Name= "MyTab2" Color="Blue" />
<Label Name = "abc" ...........>
<TextBox Name = "xyz" >
</TabItem>
</TabControl>
Here the TabControl contains TabItems ie., MyTab1 and MyTab2, but the controls viz., Name and TextBox are similar, If in my Xaml, I replicate the above entities as above, I get error(Already the controls are defined), How can I ensure, that MyTab1 & MyTab2 having same controls in a.xaml and a.xaml.cs works?

<b>To Elaborate : Let us Assume Clear/ More Clear as tab name where More Clear Tab is super set (contains all controls
of Clear Tab) and add few of its, own, but we need to retain the common names for Clear/MoreClear Tab without name collisions, in single a.Xaml and a.xaml.cs, only based on Either selections should display the contents of Clear Tab and More Clear Tab to the user, Please clarify how we could do the same?</b>
Thanks in Advance...

With Regards.

Samanth_99
Posted
Updated 14-Feb-12 18:04pm
v3

1 solution

There is nothing you have to care about. Start to define control and the tab pages, add inner structure, but perhaps without names. Use Intellisense; it won't let you to do a mistake. Run it to make sure it works and look properly. Then thing which elements you need to access via code and add names as you need them — unique names, the scope of uniqueness is your whole Window class. (The problem of your code is the lack of such uniqueness in names. Names become auto-generated class members — in case you did not get it yet :-).)

By the way, labels do not require names at all, unless you want to change their color, text, etc. dynamically in code, which I don't recommend.

Instead, they need binding with the labelled element, because main purpose of labels is to provide a keyboard shortcut (via underscore-prefixed hot key character) to a labelled element. For example:
HTML
<Label Target="{Binding ElementName=xyz}">_Abc;/Label>
where xyz is the name of your labelled TextBox, according the code sample in question.

Please see: http://msdn.microsoft.com/en-us/library/system.windows.controls.label.aspx[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900