C# 自定义控件中的WPF扩展工具包控件未通过表单?

C# 自定义控件中的WPF扩展工具包控件未通过表单?,c#,.net,wpf,xaml,xceed,C#,.net,Wpf,Xaml,Xceed,我正在使用Xceed扩展WPF工具包进行整数上下控制。我已经通过Nuget安装了这个 我已集成到一个自定义控件中,该控件包含其他普通文本框和按钮等 然后,我将此自定义控件放入窗口上的选项卡控件中。除了显示为空框的IntegerUpDown之外,所有内容都正确显示。(在设计中查看自定义控件时可以) 我已经将名称空间添加到控件和窗口中,因此不确定问题出在哪里。所有的东西都在一个项目中,所以我不认为引用是一个问题 你知道我会错过什么吗 控制XAML: <Label Grid.Row="3" Co

我正在使用Xceed扩展WPF工具包进行整数上下控制。我已经通过Nuget安装了这个

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

然后,我将此自定义控件放入窗口上的选项卡控件中。除了显示为空框的IntegerUpDown之外,所有内容都正确显示。(在设计中查看自定义控件时可以)

我已经将名称空间添加到控件和窗口中,因此不确定问题出在哪里。所有的东西都在一个项目中,所以我不认为引用是一个问题

你知道我会错过什么吗

控制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>

谢谢, Ryan这里有一个:

主窗口:

<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>

UserControl:

<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>

main窗口
UserControl
在项目结构中处于同一级别:


编辑:还有一件事,请确保您的
UserControl
完全包含在
主窗口中,并且您没有类似的内容:

这将导致IntegerUpDown看起来像一个空框,如您所述。

以下是一个:

主窗口:

<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>

UserControl:

<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>

main窗口
UserControl
在项目结构中处于同一级别:


编辑:还有一件事,请确保您的
UserControl
完全包含在
主窗口中,并且您没有类似的内容:


这将导致
IntegerUpDown
看起来像一个空框,如您所述。

请发布您的XAML.Hi。抱歉,已经为相关位添加了控件和表单XAML。您还应该为
添加完整的XAML。不幸的是,我无法做到这一点:(该控件只是控件XAML中的控件,您感兴趣的位是什么?当我使用“等效项”时),
它可以正常工作。所以,我想知道你到底在那里做了什么。请发布你的XAML.Hi。抱歉为相关位添加了控件和表单XAML。你也应该为
包含完整的XAML。很遗憾,我无法做到:(这只是控件XAML中的控件,你对哪一点感兴趣?当我使用我的“等价物”时,
它工作没有问题。所以,我想知道你到底在那里做了什么。我已经将我的用户控件复制到一个新项目中,它工作了,所以我完全不知道发生了什么哈哈!感谢你的时间、努力和帮助:)我找到了罪魁祸首!!我在app.xaml中设置了一个setter,在每个网格周围设置了5,5,5,5的边距。这显然干扰了这个控件以及我后来发现的许多其他控件。我很高兴你这么做了,恭喜!我已经将我的用户控件复制到一个新项目中,它工作正常,所以我完全不知道发生了什么。哈哈!谢谢你的time、 努力和帮助:)我找到了罪魁祸首!!我在app.xaml中使用了一个setter,在每个网格周围设置了5,5,5,5的边距。这显然干扰了此控件以及我后来发现的许多其他控件。我很高兴你做到了,恭喜!