【发布时间】:2012-11-11 20:06:49
【问题描述】:
我的解决方案中有很多项目。 在很多项目中,我有一个 TabControl。 我的项目中有一个 dll。 如何在dll中创建一个tabItem,以便在其他项目的TabControl中动态添加?
【问题讨论】:
标签: c# wpf tabcontrol tabitem
我的解决方案中有很多项目。 在很多项目中,我有一个 TabControl。 我的项目中有一个 dll。 如何在dll中创建一个tabItem,以便在其他项目的TabControl中动态添加?
【问题讨论】:
标签: c# wpf tabcontrol tabitem
您必须在您的 dll 中创建一个UserControl,然后在其他项目中引用它。
并展示您尝试过的内容以及您的问题所在,而不是提出任何搜索引擎都可以回答的简单问题,这样可以避免您投反对票。
【讨论】:
<TabItem xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Width="450" Header="StopBot" Height="362"> <Grid Background="White" Margin="0,-4,0,4"> <Label Content="Label" HorizontalAlignment="Left" Height="100" Margin="46,61,-146,-161" VerticalAlignment="Top" Width="100"/> </Grid> </TabItem>,但查看器不起作用,我无法将项目添加到 TabControl
UserControl,否则它会以<UserControl x:Class="yourUserControlName" 开头。 UserControl 是一个真正的类 (msdn.microsoft.com/en-us/library/…),而不仅仅是说它是你制作的组件。
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Width="450" Height="362"> <Grid Background="White" Margin="0,0,0,0"> <TabItem Header="StopBotAfter"> <Label Content="Label" HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100"/> </TabItem> </Grid> </UserControl>