Expression Blend doesn't recognize command objects declared in code behind file

Posted by Brian Ensink on Stack Overflow See other posts from Stack Overflow or by Brian Ensink
Published on 2010-04-08T17:49:01Z Indexed on 2010/04/21 17:23 UTC
Read the original article Hit count: 273

I have a WPF UserControl. The code behind file declares some RoutedUICommand objects which are referenced in the XAML. The application builds and runs just fine. However Expression Blend 3 cannot load the XAML in the designer and gives errors like this one:

The member "ResetCameraCommand" is not recognized or accessible.

The class and the member are both public. Building and rebuilding the project in Blend and restarting Blend hasn't helped. Any ideas what the problem is?

Here are fragments of my XAML ...

<UserControl x:Class="CAP.Visual.CameraAndLightingControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CAP.Visual;assembly=VisualApp"
Height="100" Width="700">   
    <UserControl.CommandBindings>
        <CommandBinding Command="local:CameraAndLightingControl.ResetCameraCommand" Executed="ResetCamera_Executed" CanExecute="ResetCamera_CanExecute"/>
    </UserControl.CommandBindings>
    ....

... and the code behind C#

namespace CAP.Visual
{
    public partial class CameraAndLightingControl : UserControl
    {
        public readonly static RoutedUICommand ResetCameraCommand;

        static CameraAndLightingControl()
        {
            ResetCameraCommand = new RoutedUICommand("Reset Camera", "ResetCamera", typeof(CameraAndLightingControl));
        }

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#