WPF Designer & RibbonWindow

Aug 18, 2009 at 1:45 PM

Hey,

I recently started exprimenting with the Ribbon and the RibbonWindow and I bumped into a small problem: the WPF designer of VS2008 doesn't seem to support a RibbonWindow instance at the root. Right now I'm just using a regular Window instance and I change it to RibbonWindow before publishing (run time works fine). Anybody else have this problem? Did anybody have better results using Blend maybe?

Also (just a little bug I think) I can change the Background property of the ApplicationMenu of the Ribbon and it actually changes the background color of the round button, but after the user moves the mouse over it, it doesn't change back to the right color.

Erwin

Coordinator
Aug 18, 2009 at 5:59 PM

Hi Erwin,

Hmm, I haven't had any trouble with RibbonWindow in the designer before - can you explain what happens when you change the root to RibbonWindow?  Remember that you need to change it in both the XAML and the code behind - that has always worked for me.

Yes, there are a bunch of known issues with Ribbon styling that we will be addressing in V1.  For now, just setting the background probably won't work, but if you retemplate the ApplicationMenu and change the background there and also make sure to change all of the triggers in the template to the right color (it sounds like the MouseOver trigger is hard-coded right now), you should be able to get it to work.  These kinds of things should be easier to do and should not require retemplating in V1, but in the CTP we unfortunately have a bunch of hard-coded values in the templates which make it difficult to change the Ribbon's look by just setting Ribbon properties.

Thanks!
Samantha

Aug 19, 2009 at 6:45 AM
Edited Aug 19, 2009 at 8:58 AM

Hi Samantha,

Thanks for the quick reply. After I change the Window instance to RibbonWindow (yes, also in the code behind), the designer gives me the message "Problem Loading     The document contains errors that must be fixed before the designer can be loaded. Reload the designer after you have fixed the errors.". When I reload the designer it gives me the following exception:

Type 'MS.Internal.Permissions.UserInitiatedNavigationPermission' in Assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.

I was still using the RTM version of VS2008, so I installed SP1, but that didn't change anything. I might try 'repairing' VS2008 later today.

Thanks,
Erwin

Edit: I repaired VS2008 and installed all available updates, but I still get the same error. I also tried creating a new project from scratch: I created a new wpf application, added the reference to the Ribbon library, added the ribbon namespace to the xaml and code behind and changed the root instance from Window to RibbonWindow. But even then I get the same error.

<r:RibbonWindow x:Class="RibbonTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
    Title="Window1" Height="300" Width="300">
    <Grid>
        
    </Grid>
</r:RibbonWindow>
 ...
using Microsoft.Windows.Controls.Ribbon;

namespace RibbonTest
{
    public partial class Window1 : RibbonWindow
    {
        public Window1()
        {
            InitializeComponent();
        }
    }
}
Aug 25, 2009 at 9:55 AM

Could somebody confirm I'm doing the right thing here? I would like to know if I missed something or that this is a bug. To clarify: the code compiles and runs fine. It's only the WPF designer which is not cooperating.

Nov 28, 2010 at 5:07 PM

I think your problem is with the following namespace:

xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"

I have the same problem. I created a UserControl, compiled it. Then, I created a wpf app to test it, added the namespace, rebuilt my solution and as soon as the solution was rebuilt the designer didn't load. If I run the app it
works ok. I read somewhere that the problem is with vs 2008 and no solution was provided.