Page 1 of 1

Loaded event inside DataTemplate.Triggers not working properly

Posted: 07 Sep 2021, 13:18
by Sumel007
Hi,

I have ran into a problem which I believe to be a bug. I have put a "Loaded" RoutedEvent EventTrigger inside of my DataTemplate to play a storyboard. The xaml works properly in WPF, but it desn't work in Noesis. I am getting the following error:
[NOESIS/E] <memory>(26): Unknown event 'Loaded' setting EventTrigger.RoutedEvent.
You can see the xaml code below. The item source of the listbox is set in code behind.
<Window x:Class="GlutMenu.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="#FF000000"
        Title="MainWindow" Height="1080" Width="1920" Focusable="False">
    <Window.Resources>
        <DataTemplate x:Key="MessageItemTemplate">
            <DataTemplate.Resources>
                <Storyboard x:Key="ItemShownStoryboard">
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Info_Box" Storyboard.TargetProperty="(UIElement.Opacity)">
                        <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
                        <EasingDoubleKeyFrame KeyTime="00:00:03" Value="1"/>
                        <EasingDoubleKeyFrame KeyTime="00:00:03.7" Value="0"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </DataTemplate.Resources>
            <StackPanel x:Name="Info_Box" RenderTransformOrigin="0.5,1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Opacity="1" Background="#FFEE5858">
                <TextBlock Text="{Binding}">
                </TextBlock>
            </StackPanel>
            <DataTemplate.Triggers>
                <EventTrigger RoutedEvent="Loaded">
                    <BeginStoryboard Storyboard="{StaticResource ItemShownStoryboard}" />
                </EventTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <ListBox x:Name="mainListBox" ItemTemplate="{StaticResource MessageItemTemplate}" Background="#FFF0E3E3" BorderBrush="{x:Null}" Margin="0,0,828,228" />
    </Grid>
</Window>
    
I have managed to work around this issue for now by using the triggers inside stackpanel instead, like so.
                    
                    <StackPanel.Triggers>
                        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                            <BeginStoryboard Storyboard="{StaticResource ItemShownStoryboard}" />
                        </EventTrigger>
                    </StackPanel.Triggers>
                    

Re: Loaded event inside DataTemplate.Triggers not working properly

Posted: 08 Sep 2021, 09:49
by sfernandez
Hi,

This seems to be a bug in the RoutedEventConverter that is not able to convert the event name without specifying the type. Could you please report it in our bugtracker?

In the meantime you can use the following (even inside the DataTemplate.Triggers):
<EventTrigger RoutedEvent="FrameworkElement.Loaded">

Re: Loaded event inside DataTemplate.Triggers not working properly

Posted: 09 Sep 2021, 12:57
by sfernandez
Created issue #2107 to track this problem.