Search code examples
c#.netwpfxamlxceed

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


I am using the Xceed Extended WPF Toolkit for the Integer Up Down Control. I have installed this via Nuget.

I have the integrated into a custom control which contains other normal textboxes and button etc.

This custom control I then put in a tab control on a Window. Everything shows correctly apart from this IntegerUpDown which shows as an empty box. (It is fine when looking at the custom control in design)

I have added the namespace to both the control and window so am not sure what the problem is. Everything is inside one project so I don't think references are a problem.

Any ideas of what I could be missing?

Control XAML:

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

Form XAML:

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

Thanks, Ryan


Solution

  • Here's a MCVE:

    MainWindow:

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

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

    enter image description here

    Both MainWindow and UserControl are at the same level in the project structure:

    enter image description here


    EDIT: One more thing, make sure your UserControl is fully contained by the MainWindow and you do NOT have something like this:

    enter image description here

    That would cause the IntegerUpDown look like an empty box, like you described.