tags:

views:

92

answers:

1

Hi,

I hope I am able to illustrate the problem using a lot of images. First of all, I was no real fan of XAML (Silverlight issues, crashes in Preview, and so on...)

Now, with VS2010 the situation has become better. There are still a lot of things I like better in code, but I also want a preview in my VS.

So, take a look at the following control: It is really simple, a todo details list. The first screenshot shows the code of the control, pretty straighforward:

CodebasedControl

There is no XAML, so obviously no preview. Of course, I could encapsulate it in another control, like shown in the next screenshot:

CodebasedControl

But, in that case I have an additional file I do not want or need. So I had the idea to move the init stuff inside the contructor of a XAML control. For simplicity, I used simple elements. But they do not show up in the preview...

CodebasedControl

CodebasedControl

Finally, I know I could use the controls in other parts of my app when creating UIs. But I am using layout manager, PRISM and a lot of other stuff, so I just want an easy preview of some specific control I created (without having to have a XAML wrapper file for each control)

Thanks for help, and sorry for the post structure, but I though with images it is better to understand...

Chris

+1  A: 

Ok,

I found a way. Basically I am tricking VS by changing the XAML, but keeping the code-behind linked to the file. It the same like the wrapper solution, but without having a dedicated extra class or file. I am using the "xaml-infront" file for preview.

This solution only works with pure code controls, I have to do more research for mixed controls (at least I think so.. but it is enough for me for now).

Please be aware, the code behind is NOT partial anymore. It could be placed anywhere else, what I am doing here is basically only related to file-names and visual studio "readability"..

See screenshots for explanation:

alt text

Some space for easier reading

alt text

Christian