tags:

views:

473

answers:

2

Hi all,

I have a xaml form for use in my application, and i have subclassed the Frame class to create my own, and edited the interface to specify my own class for the content (as i need to access properties on the content for data binding).

The problem comes then in the designer that the compiler says it cannot create an instance of my control - i've tried to do some designer checks on the offending property bit but that didnt work either.

How can i get the control to display? Works fine at runtime...

Xaml:

<Grid Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2">
 <views:PageFrame Name="Content_MainPage" Frame.NavigationUIVisibility="Hidden"/>                    
</Grid>

CS:

        public new BaseView Content 
    {
        get
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return new BaseView();
            }
            else
            {
                return (BaseView)base.Content;
            }
        }
        set
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                base.Content = new BaseView();
                FrameTitle = "design mode";
            }
            else
            {
                base.Content = value;
                FrameTitle = value.Title;
            }
        }
    }
A: 

I came across a similar problem when creating my own Panel class.

Is your PageFrame class defined in the same assembly that your XAML lives in?

I found the only way I could get this to work was to move my "PageFrame" class into a new assembly. From memory I think I even had to build that assembly ahead of time, so that the assembly could be referenced via a file reference (as opposed to a project reference).

I hated this solution, so I hope you find a cleaner one :)

Have you got VS2008 SP1 installed? I had hoped MS would fix this bug. I haven't tried removing my workaround to check...

Antony Perkov
I think a 'Hi' is in order too...;-)
simonjpascoe
A: 

Its in the same assembly - and yes I have VS2008 SP1 installed too. Not that removing the above property lets it work fine from a vs point of view, but obviously not from my point of view!

I will give this a go - thanks Antony.

simonjpascoe
No problem. BTW: didn't we used to work together?
Antony Perkov
Yes, I figured so indeed ! Hope all is going well.
simonjpascoe
Things are good here. Hope your move to Asia is working out well. Let me know how you get on with your designer problem...
Antony Perkov