locked
EventSetter XAML Error RRS feed

  • Question

  • I have a couple of ListViewItem styles in which I use the same EventSetter. My code compiles and runs as intended, but in Expression Blend 2 (February 2008 Beta) I get a persistent error on the second EventSetter.

    "Cannot load XAML file that has EventSetters. Try compiling the XAML. Line '63' Position '8'."

    Has anyone ever encountered this error? It prevents me from visually editing the control that is using the second style.

    Here are the two styles:

    <Style x:Key="Style_lviSAJobs" 
        TargetType="{x:Type Classes:MyListViewItem}">  
        <EventSetter Event="UIElement.PreviewMouseLeftButtonDown" Handler="lvi_PreviewMouseLeftButtonDown"/>  
        <Setter Property="IsEnabled" Value="{Binding Path=TechCode, Converter={StaticResource cvtTechCodeBool}}"/>  
        <Style.Triggers> 
            <DataTrigger  
                Binding="{Binding Path=JobFinished}" 
                Value="True">  
                <Setter  
                    Property="Background" 
                    Value="{StaticResource Brush_GradientGreen}"/>  
            </DataTrigger> 
        </Style.Triggers> 
    </Style> 
    <Style x:Key="Style_lviJobAssignments" 
        TargetType="{x:Type Classes:MyListViewItem}">  
        <EventSetter Event="UIElement.PreviewMouseLeftButtonDown" Handler="lvi_PreviewMouseLeftButtonDown"/>  
        <Style.Triggers> 
            <DataTrigger  
                Binding="{Binding Path=JobFinished}" 
                Value="True">  
                <Setter  
                    Property="Background" 
                    Value="{StaticResource Brush_GradientGreen}"/>  
            </DataTrigger> 
        </Style.Triggers> 
    </Style> 
    Thursday, April 17, 2008 6:00 PM

All replies

  • I don't have the February Beta any more, but I just tried with the following XAML on our latest Blend 2 build
    <Window  
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        x:Class="UntitledProject13.Window1" 
        x:Name="Window" 
        Title="Window1" 
        Width="640" Height="480">  
        <Window.Resources> 
            <Style x:Key="ButtonStyle1" BasedOn="{x:Null}" TargetType="{x:Type Button}">  
                <EventSetter Event="Button.Click" Handler="OnMouseLeftButtonUp"/>  
            </Style> 
        </Window.Resources> 
     
        <Grid x:Name="LayoutRoot">  
            <Button Margin="196,135,306,0" Style="{DynamicResource ButtonStyle1}" VerticalAlignment="Top" Height="72" Content="Button"/>  
        </Grid> 
    </Window> 
     and it seems to work for me. Does it work for you? If it does, then you will have to send over a project repro.

    Thanks,
    -Unni
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, April 18, 2008 12:39 AM
  • We have the same issue. With Blend 1.0 it would display the error but still allow us to design the control.  With Blend 2.0 the problem is worse, the entire control is undesignable.  There is nothing wrong with the code, it compiles and runs fine, and the "Cider" designer in Visual Studio 2008 has no problem with it at all, this is a Blend Bug!!!

    I have a simple project that demonstrates the problem if anyone at Microsoft can take a look at it.

     

     

    Monday, September 29, 2008 5:37 PM
  • You can send it over to unnir at microsoft dot com, and I will take  look.

    Thanks,
    Unni

    Tuesday, September 30, 2008 6:59 AM
    Moderator
  • Unni Ravindranathan MSFT said:

    You can send it over to unnir at microsoft dot com, and I will take  look.



    done, thanks Unni!
    Tuesday, September 30, 2008 4:00 PM
  • Hi,

     

    i am using VS2010 ultimate. i still face this issue.

    System.Windows.Markup.XamlParseException occurred
      Message='./abc.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'. Cannot load XAML file that has EventSetters. Try compiling the XAML. Line '222' Position '10'.  Error at object 'System.Windows.ResourceDictionary' in markup file 'Schwab.Parts.WatchList;component/watchlistview.xaml' Line 25 Position 37.

    How to resolve it????

     

    Friday, July 8, 2011 3:54 PM