【发布时间】:2014-12-13 01:34:18
【问题描述】:
我的名字是 Andrea,这是我的第一篇文章。
作为一个简单的读者,你经常帮助我,现在我写信是因为我想直接支持。
我必须创建一个选项卡控件,并使用“添加选项卡”按钮添加一个具有相同内容的新选项卡。 到目前为止一切都很好。
在选项卡中,我有一个文本编辑器和一个组合框。 我的问题有两个:
1 如何为我添加的每个选项卡加载组合框的内容? 2 每次我编写一个编辑选项卡覆盖的文本时,也会编辑另一个选项卡的文本。
代码如下:
Xaml 中的数据模板:
<DataTemplate x:Key="tabItemContent">
<dxlc:LayoutGroup Orientation="Vertical" Header="Target Description" IsCollapsible="True">
<!--Name-->
<dxlc:LayoutItem>
<dxlc:LayoutGroup Orientation="Horizontal" ItemSpace="4" >
<dxlc:LayoutItem Label="Name" Margin="10">
<dxe:TextEdit x:Name="TextEdit_NameTarget"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
</dxlc:LayoutItem>
<!--Nation e Label-->
<dxlc:LayoutItem>
<dxlc:LayoutGroup Orientation="Horizontal" ItemSpace="12" >
<dxlc:LayoutItem Label="Nation" Margin="10">
<ComboBox x:Name="ComboBox_TargetNazione" />
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
</DataTemplate>
C#:
private void Button_Click_Add(object sender, RoutedEventArgs e)
{
DataTemplate tabItemDataTemplate = this.TryFindResource("tabItemContent") as DataTemplate;
DXTabItem tabItem = new DXTabItem();
tabItem.Header = "New Tab";
tabItem.ContentTemplate = tabItemDataTemplate;
tabControl_Targets.Items.Add(tabItem);
}
这里是将列表加载到组合框中的位置:
private void LoadComboBoxNation()
{
ComboBox_TargetNazione.ItemsSource =
ManagementTriple.Istance().get_Nation_byTipologyAndContext(ComboBox_TypologyScenario.SelectedItem.ToString(),
ComboBox_ContextScenario.SelectedItem.ToString());
controlloselecteditem(ComboBox_SourceNazione.SelectedItem.ToString());
controlloselecteditem(ComboBox_TargetNazione.SelectedItem.ToString());
}
感谢大家给我的帮助。
【问题讨论】:
标签: c# wpf visual-studio-2010 devexpress tabcontrol