Skip to main content
Home Forums General Silverlight New Features in Silverlight 3 Problem previewing XAML in .NET 2008 IDE??
17 replies. Latest Post by tfierens on July 4, 2009.
(0)
tfierens
Member
1 points
16 Posts
06-29-2009 7:57 PM |
Hi everyone,
I'm just wondering if anyone had any resolution to my problem as it is seriously irretating. Everytime I try to open a XAML file in my IDE (.NET 2008), it fails to build the preview correctly and just displays a gray box (with the zoom slider) on the side but no actual view displaying the various controls that should be displayed.
We recently got a project contracted out and I'd really like to get cracking on the various part of it but not being able to preview the XAML is an absolute nightmare.
This is obviously an issue with .NET as we have this on all our development machines. While the project that was contracted out was rather large and M.V.VM pattern was used to develop it, it is extremely well broken down and it should not have any issues opening these XAML files but yet it fails all the time but the size of the project or the pattern used to develop it does not seem to be the problem as when I started with SL2, I had the problem but since most projects were just me experimenting with SL2 it was not an issue but now that we've had this written with SL3 and we'll seriously like to get started, this is causing a serious problem as it pretty much seem to be happening with all projects whether big or small.
Most of the time, I have no problem with the preview for my smaller projects in MS Blend but the larger project we got contracted out has some nice features used in it which are not supported by Blend and therefore is not a solution either.
The fact that we have this on all our development machines makes me wonder whether this is a bug or not??? Also note that I completely removed SL3 and .NET 2008, actually removed all relevant folder and re-installed the lot and still no good!!
Does anyone have any ideas/resolutions? Is this a known bug?
Thanks.
Thierry.
ksleung
Contributor
5198 points
993 Posts
06-29-2009 10:49 PM |
Not sure I have the same issue as yours but my VS 2008 Xaml preview is also completely broken. Previously it was fine, but then I upgraded to 2010 only to find that it was not working for me (way too slow and consumes too much memory), and then I downgraded to VS 2008, which works except that the Xaml preview is broken. I guess unless you have a really really clean install, the whole VS install experience is not bullet-proof.
My solution? Actually more like a workaround, which is to install Visual Web Developer 2008. I can at least see the Xaml Preview correctly. I switch between VS2008 and VWD2008, though nowadays I am mostly in VWD2008.
06-30-2009 5:55 AM |
Hi,
Thanks for that. I'll try what you suggested. Not ideal, but at least if it displays a preview properly, it will be a big help... Hopefully other people have had this problem and maybe will have other suggestions.
T.
Tim Dawson
Participant
1092 points
209 Posts
06-30-2009 6:17 AM |
SL3 will be released in the near future. At that point you can open your solution in a non-beta product, and things should work a lot better.
06-30-2009 6:26 AM |
Hi Tim,
Thanks for your feedback but I already had this problem (and so have my colleagues) with SL2...
I've been seriously impressed with what you can do but it really is making thing akwards when working with UI. Is there other tools out there that will handle this better than the .NET 2008 IDE?
06-30-2009 6:44 AM |
Highly unlikely. Perhaps you could post a sample of the errant XAML here, so people can suggest how you could change it to make it designer-friendly.
06-30-2009 7:05 AM |
Note that installing Web Express 2008 did not resolve my problem as it does not support various features supported by .NET 2008 professional. I get a lot of errors when trying to load the project. I've try to just load the XAML but that made no difference.
When I open the XAML file, all the problems seem to be related to the fact that it is using a resource file. All of information seems to be stored in it. Everything from strings, graphics, etc... are stored in a resource file.
This is the line where it display an error:
The error displayed is: AG_E_UNKNOWN_ERROR
If I temporarily remove this, then the code below this give me an error that it cannot find the specific resource file.
The line highlighted above then displays the error:
Cannot find a resource with the name/key MenuHeaderTextStyle
Even after removing everything to do with resource files, it still will not display correctly. Below is the code without any resource file/binding/etc... left in it:
<
</
Note that the full project was designed using M.V.VM pattern and compile perfectly, so the problem solely lies in previewing the views in the .NET IDE but what I don't understand is while resource files could potential be badly handled by the .NET IDE, why is it still not working when all this is removed and you are left with basic XAML code.
06-30-2009 7:15 AM |
Let's work backwards from the last example you posted, which doesn't even have any resources. Does it work when you add back explicit Width and Height attributes on the page?
06-30-2009 2:48 PM |
My apologies for only getting back to you now! I communicating via my personal account and completely forgot to check it as I got caught up with other things at work.
I've tried what you suggested and it still isn't working.
06-30-2009 5:22 PM |
Actually that's not entirely surprising as the last example you gave didn't include a single piece of displayable content. I tried it, and I got nothing too, until I set the text of one of the TextBlocks at which point it showed up like I'd expect.
06-30-2009 5:33 PM |
Correct, I tried it as well and it is working now. So, it seems that the IDE does not handle reading from resource files then? Is that it?
This was the original code:
<navigation:Page x:Class="WebAdministration.Views.ManageGroups" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" xmlns:local="clr-namespace:WebAdministration.Views" xmlns:controls="clr-namespace:WebAdministration.Controls" xmlns:rs="clr-namespace:WebAdministration.Resources" Title="Manage Groups">
<navigation:Page.Resources> <local:ManageGroupsModel x:Key="GroupsModel" /> <rs:ManageGroupsControlResources x:Key="ControlResources" /> </navigation:Page.Resources>
<TextBlock x:Name="pageTitle" Style="{StaticResource MenuHeaderTextStyle}" Text="{Binding ManageGroupsPageTitle, Source={StaticResource ControlResources}}" /> <TextBlock x:Name="pageText" Style="{StaticResource MenuHeaderTextStyle}" Text="{Binding ManageGroupsPageDetails, Source={StaticResource ControlResources}}" />
What do you think?
06-30-2009 5:50 PM |
Are both those things you've included in your Resources property ResourceDictionaries? If so, I would try explicitly surrounding them in a ResourceDictionary with MergedDictionaries, like so:
<page.REsources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <!-- your merged dictionaries go here --> </REsourceDictionary.MergedDictionaries>
This is untested, off the top of my head.
06-30-2009 7:28 PM |
I'm not 100% familiar with SL, so I can't tell if this can be done in an another way or not but I did a search for ResourceDictionary in my entire solution and it did not find it, so to answer your question, I guess it's a no.
I'll go research this now and see if I can figure out what to do and I'll get back to you.
06-30-2009 8:13 PM |
I tried the following:
<rs:ManageGroupsControlResources x:Key="ControlResources" />
but I get 2 errors being highlighted on the line in bold telling me that: key attribute can be used only on a tag contained in an IDictionary type property.
I've had a look at what these resources are and one of them is an actual resource file (.resx) containing all the string for the buttons, labels, etc... the other one is referring to the model class where part (or all) of the logic for this is implemented.
The strange thing is that intellisense is picking up everything ok as there is a reference for these as defined above:
xmlns:rs="clr-namespace:WebAdministration.Resources" (for the resource file)
From the error I got, these are not of type IDictionary, so I guess this won't work. Any other ideas?
07-01-2009 4:51 AM |
I assumed they were ResourceDictionaries. I hadn't actually thought of trying to use .resx files with XAML since normally you'd just use ResourceDictionaties. There's a new theory as to why the designer doesn't understand them, anyway.
I saw in your previous code a reference to {StaticResource MenuHeaderTextStyle}, which doesn't appear in your resources. That's why I assumed they were ResourceDictionaries containing further resources.
07-03-2009 8:49 PM |
Hi Tim, everyone
Sorry first change I've had to get back to the issue.
Has anyone anymore suggestions as to what I could do to handle this issue I'm obviously having with the .NET IDE and the fact that my XAML is not handling .resx file in the preview window?? Remember, compiling is not an issue and works a charm, but without being able to preview your view, it makes it very hard to try to work or modify anything.
Any additional feedback would be greatly appreciated.
codenenterp
36 points
13 Posts
07-04-2009 12:25 AM |
Yeah I have trouble in vs as well. The best thing i can say is try and use blend.
07-04-2009 6:41 PM |
That's what I usually do but in this case Blend does not like this code either which is a complete pain!