locked
Copied XAML from one project to another, seeing error RRS feed

  • Question

  • Hi,

     

    I have the following simple XAML designer, DropHere.xaml, which I copied from one C# class library project to another.  The only change I made in the source was changing the namespace in both DropHere.xaml and DropHere.xaml.cs.  Both projects are .NET 4.0 class libraries 

    However, in the new copy, I'm getting errors.  

    Here's the source code:

     

    <sap:ActivityDesigner x:Class="TryActivities.DropHere"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
        xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">
        <sap:ActivityDesigner.Resources>
            <!-- Collapse Data Template for Designer -->
            <DataTemplate x:Key="Collapsed">
                <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <TextBlock FontStyle="Italic" Foreground="Gray" HorizontalAlignment="Center">Double-click to view</TextBlock>
                </StackPanel>
            </DataTemplate>
            <DataTemplate x:Key="Expanded">
                <StackPanel>
                    <sap:WorkflowItemPresenter Item="{Binding Path=ModelItem.Body, Mode=TwoWay}"
                                            HintText="Drop activity here" />
                </StackPanel>
            </DataTemplate>
            
            <!-- Expand/Collapse Style for Designer -->
            <Style x:Key="ExpandOrCollapsedStyle" TargetType="{x:Type ContentPresenter}">
                <Setter Property="ContentTemplate" Value="{DynamicResource Expanded}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="false">
                        <Setter Property="ContentTemplate" Value="{DynamicResource Collapsed}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

        </sap:ActivityDesigner.Resources>
        <Grid >
            <ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}"/>
        </Grid>

    </sap:ActivityDesigner>

     

     

    namespace TryActivities
    {
        // Interaction logic for DropHere.xaml
        public partial class DropHere
        {
            public DropHere()
            {
                InitializeComponent();
            }
        }
    }

     

    And here's the error:

     

    Type 'http://schemas.microsoft.com/winfx/2006/xaml/presentation:StackPanel' is not assignable to type 'http://schemas.microsoft.com/winfx/2006/xaml/presentation:FrameworkElementFactory' of member 'VisualTree'. File: DropHere.xaml Line: 14 Column: 14 Project: TryActivities

    It actually has this error twice, once for each StackPanel.
    What does this error mean? And why am I only getting it in my new project? 

     





    Friday, September 30, 2011 4:36 PM

Answers

  • I figured it out.  When I copied the file, the BuildAction went from "Page" to "XamlAppDef".  Changing it back to "Page" cured this error.
    Friday, September 30, 2011 6:19 PM