自定义控件中的 WPF 扩展工具包控件没有通过表单?

WPF Extended Toolkit Control in Custom Control not pulling through to form?

我正在使用 Xceed Extended WPF Toolkit 进行整数上下控制。我已经通过 Nuget 安装了它。

我已经集成到一个包含其他普通文本框和按钮等的自定义控件中。

然后我将此自定义控件放在 Window 上的选项卡控件中。除了显示为空框的 IntegerUpDown 之外,一切都正确显示。 (设计时看自定义控件就好了)

我已经将命名空间添加到控件和 window 所以我不确定问题出在哪里。一切都在一个项目中,所以我认为引用不是问题。

有什么我可能遗漏的想法吗?

对照XAML:

<Label Grid.Row="3" Content="Quantity of Tickets:" VerticalAlignment="Center"></Label>
<xctk:IntegerUpDown Grid.Row="3" Grid.Column="1" Name="numTickets"></xctk:IntegerUpDown>

表格XAML:

<TabItem Header="New Booking">
      <Grid Background="#FFE5E5E5">
           <btc:NewBooking></btc:NewBooking>
      </Grid>
 </TabItem>

谢谢, 瑞安

这是一个MCVE

主窗口:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApplication8"
    x:Class="WpfApplication8.MainWindow"
    mc:Ignorable="d"
    Title="MainWindow" Height="300" Width="300">
<Grid>
    <TabControl x:Name="tabControl" Margin="0">
        <TabItem Header="TabItem 1">
            <Grid Background="#FFE5E5E5">
                <local:UserControl1></local:UserControl1>
            </Grid>
        </TabItem>
        <TabItem Header="TabItem 2">
            <Grid Background="#FFE5E5E5"/>
        </TabItem>
    </TabControl>
</Grid>

用户控件:

<UserControl x:Class="WpfApplication8.UserControl1"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" 
         xmlns:local="clr-namespace:WpfApplication8"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<Grid>
    <StackPanel>
        <Label Grid.Row="3" Content="Quantity of Tickets:" VerticalAlignment="Center"></Label>
        <xctk:IntegerUpDown Grid.Row="3" Grid.Column="1" Name="numTickets"></xctk:IntegerUpDown>
    </StackPanel>
</Grid>

MainWindowUserControl在项目结构中处于同一层级:


编辑: 还有一件事,请确保您的 UserControl 完全包含在 MainWindow 中并且您没有这样的东西:

这会导致 IntegerUpDown 看起来像一个空盒子,就像您描述的那样。