none
Cannot have nested BeginInit calls on the same instance. RRS feed

  • Question

  • I've created my own UserControl named DesignerPanel. It inherits UserControlBase, which inherits UserControl. During runtime everything is ok, but Cider is not able to render the XAML as there is the following error message:

    Error 172: Cannot have nested BeginInit calls on the same instance.

    I don't really understand why this error occures. There are no manually BeginInit() calls or something like that. Can someone explain that to me?

    Thank you in advance,
    Norbert
    Friday, November 30, 2007 10:08 AM

Answers

  • Hi Norbert

     

    Base on my understanding, I think that this is because every custom UserControl or Window can only has one XAML file associated with it. For example, either DesignerPanel or UserControlBase can has a XAML file associated with them. The following code is an example which works well. Further more, I'm using Visual Studio 2008 RTM.

     

    Code Block

    public partial class MyUserControl : BaseUserControl

    {

        public MyUserControl()

        {

            InitializeComponent();

        }

    }

     

    public class BaseUserControl : UserControl

    {

    }

     

    <local:BaseUserControl x:Class="ForumProjects.MyUserControl"

                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

                xmlns:local="clr-namespace:ForumProjects"

                Height="300" Width="300">

        <Button Width="75" Height="25">Go</Button>

    </local:BaseUserControl>

     

    <Window x:Class="ForumProjects.MainWindow"

           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

           xmlns:local="clr-namespace:ForumProjects"

           x:Name="TheWindow" Title="MainWindow" Height="600" Width="800">

        <StackPanel>

            <local:MyUserControl Width="100" Height="100"/>

        </StackPanel>

    </Window>

     

     

    Best Regards,

    Wei Zhou

    Monday, December 3, 2007 9:49 AM
    Moderator