ChildWindow Design Error

Feb 1, 2012 at 10:06 AM

I am using the childwindow in my VB.Net WPF application (.Net framework v4.0). I am having a problem with the ChildWindow in that when I view the dialog as XAML, everything seems fine. I then click DESIGN to view the layout and I get the following error:

NullReferenceException was thrown due to the document error: Object Reference not set to an instance of an object.

I then return to the XAML to find that all code is highlighted in red with the following error:

Object reference not set to an instance of an object.

I cannot identify why this error is occuring or how to fix it? Does anybody have any ideas or a solution?

Here is the XAML I have used to define the login dialog.

<extToolkit:ChildWindow x:Class="LoginDialog"
    xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Caption="My Child Window" Height="246" Width="404" IsModal="True">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="52*" />
            <RowDefinition Height="106*" />
            <RowDefinition Height="49*" />
        </Grid.RowDefinitions>
        <Button Content="Cancel" Grid.Row="2" HorizontalAlignment="Right" Margin="0,0,8,8" Name="btnCancel" Width="81" Height="36.236" VerticalAlignment="Bottom" />
        <Button Content="OK" Height="36.236" HorizontalAlignment="Right" Margin="0,0,93,8" Name="btnOK" VerticalAlignment="Bottom" Width="81" Grid.Row="2" />
        <Image Height="52" HorizontalAlignment="Left" Name="imgIcon" Stretch="None" VerticalAlignment="Top" Width="52" Source="/Minster.Portal;component/Images/Login48x48.gif" />
        <CheckBox Content="Remember these details" Grid.Row="2" Height="21" HorizontalAlignment="Left" Margin="-20,91.236,0,0" Name="CheckBox1" VerticalAlignment="Top" Width="163" />
        <Label Content="Login Dialog" Height="39" HorizontalAlignment="Left" Margin="43,0,0,0" Name="lblTitle" VerticalAlignment="Top" FontSize="24" Width="331" Padding="0" />
        <Label Content="Please enter your login details below to access the system" Height="22" HorizontalAlignment="Left" Margin="43,30,0,0" Name="lblSubTitle" VerticalAlignment="Top" Padding="0" Width="331" />
        <Label Content="Enter your username" Height="23" HorizontalAlignment="Left" Margin="21,14,0,0" Name="lblUsername" Padding="0" VerticalAlignment="Top" Width="122" Grid.Row="1" />
        <TextBox Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="149,14,0,0" Name="txtUsername" VerticalAlignment="Top" Width="202" />
        <Label Content="Enter your password" Height="23" HorizontalAlignment="Left" Margin="21,43,0,0" Name="lblPassword" Padding="0" VerticalAlignment="Top" Width="122" Grid.Row="1" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="149,43,0,0" Name="txtPassword" VerticalAlignment="Top" Width="202" Grid.Row="1" />
        <Label Content="Select warehouse" Height="23" HorizontalAlignment="Left" Margin="21,72,0,0" Name="lblWarehouse" Padding="0" VerticalAlignment="Top" Width="122" Grid.Row="1" />
        <ComboBox Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="149,72,0,0" Name="cboWarehouse" VerticalAlignment="Top" Width="202" Background="White" BorderBrush="LightGray" />
        <Path Data="M0,52 L384,52" Fill="#FFF4F4F5" Height="1" Margin="0" Stretch="Fill" Stroke="Black" VerticalAlignment="Bottom" StrokeThickness="4"/>
    </Grid>
</extToolkit:ChildWindow>

Sep 28, 2012 at 7:44 AM

I'm having a similar problem in a C# application. I recently reorganized project folder structure to more closely match the way the projects are organized in the solution. This was mostly done outside of Visual Studio, and of course resulted in most of the projects turning up as missing in the Solution Explorer. when I browsed to the correct files from the project properties all seemed well and after re-downloading the requisite packages with NuGet I got it to compile again. The application runs fine, but I can't get the IntergerUpDown control to work in design view. 

The form is displayed in the designer, but any content control with a IntegerUpDown control will not display at all - like setting the visibility on the container to collapsed. In addition each IntegerUpDown control on a form that is open in Visual Studio adds an error to the error list and clutters up the list. This means that I have to close all such forms before doing any debugging.

The problem occurs on several computers where I edit the same solution. I'm thinking that a file is missing that the Visual Studio designer needs, but I have not been able to track down the culprit

 

Cato

Developer
Oct 29, 2012 at 1:46 PM

for the ChildWindow Error, putting all this code snippet in between "Grid" tag fixed the issue.

For the ContentControl containing an invisible IntegerUpDown, when using this code in the Designer :

<Grid x:Name="LayoutRoot">
		<StackPanel>
			<xctk:ColorPicker Width="100" Height="50" />
			<xctk:IntegerUpDown Width="100" Height="50"/>
			<ContentControl Width="100" Height="50">
				<xctk:IntegerUpDown />
			</ContentControl>
		</StackPanel>
	</Grid>

the small rectangle representing the Up and Down arrows are seen which is a representation of the IntegerUpDown. with no values.

What exact error do you see ? Can you provide more infos?