It is impossible to clone TabItems from an existing one without using XamlReader and XamlWriter. You can, however, define a template for creating new TabItems. The template has to be created in your xaml file in Window resources.
<Window.Resources>
<DataTemplate x:Key="tabItemContent">
<Canvas Margin="0,0,0,0" Name="tabPracownikCanvas" Visibility="Visible">
<ListBox Canvas.Left="0" Canvas.Top="-0.004" Height="229.977" Name="listBox1" Width="152.207">
<ListBoxItem>Dane osobowe</ListBoxItem>
</ListBox>
<RichTextBox Canvas.Left="0" Canvas.Top="261.085" Height="246.642" Name="richTextBoxBasicInfo" Width="152.207" IsReadOnly="True"/>
<Label Canvas.Left="0" Canvas.Top="233.31" Height="27.775" Name="label1" Width="152.207" Content="SomeTextHere">
</Label>
<Canvas Canvas.Left="155.54" Canvas.Top="-0.018" Height="507.745" Name="canvasWithDetailedInfo" Width="430.731" >
</Canvas>
</Canvas>
</DataTemplate>
</Window.Resources>
To add new tabItem just do the following:
TabItem item = new TabItem();
item.Header = "New item";
item.ContentTemplate = TryFindResource("tabItemContent") as DataTemplate;
tabControl2.Items.Add(item);
YOU CANNOT change the contents which were created dynamically just through children editing. You need to bind some properties.
e.g. we will bind label contents:
create a class:
class Person
{
public string Name { get; set; }
public string Surname { get; set; }
}
change the label content to binding:
<Label Canvas.Left="0" Canvas.Top="233.31" Height="27.775" Name="label1" Width="152.207" Content="{Binding Name}">
change the Item’s content:
item.Content = new Person() { Name = "dupa", Surname = "xxxx" }
It will automatically change the label’s content when you change item.Content.Name property.
You can also do it in this way:
ReplyDelete< Label Canvas.Left="0" Canvas.Top="233.31" Height="27.775" Name="label1" Width="152.207">
< /Label>
WPF Charts developing can be tricky, especially if you're an inexperienced developer. Thankfully there are these great WPF charting posts available on the web, such as this one, that help us those inexperienced developers gather knowledge about iOS Charts, Android charts and other types of WPF charts. Thank you for your post.
ReplyDeleteaşk kitapları
ReplyDeletetiktok takipçi satın al
instagram beğeni satın al
youtube abone satın al
twitter takipçi satın al
tiktok beğeni satın al
tiktok izlenme satın al
twitter takipçi satın al
tiktok takipçi satın al
youtube abone satın al
tiktok beğeni satın al
instagram beğeni satın al
trend topic satın al
trend topic satın al
youtube abone satın al
takipçi satın al
beğeni satın al
tiktok izlenme satın al
sms onay
youtube izlenme satın al
tiktok beğeni satın al
sms onay
sms onay
perde modelleri
instagram takipçi satın al
takipçi satın al
tiktok jeton hilesi
instagram takipçi satın al pubg uc satın al
sultanbet
marsbahis
betboo
betboo
betboo
thanks admin great article HDE Bilişim
ReplyDeleteAlışveriş
Compo Expert
Multitek
Seokoloji
Vezir Sosyal Medya
Adak
Maltepe Adak
Fixed matches tips ht ft
ReplyDeleteFootball prediction