Sumel007
Topic Author
Posts: 30
Joined: 19 Mar 2020, 10:50

Loaded event inside DataTemplate.Triggers not working properly

07 Sep 2021, 13:18

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>
                    
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Loaded event inside DataTemplate.Triggers not working properly

08 Sep 2021, 09:49

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">
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Loaded event inside DataTemplate.Triggers not working properly

09 Sep 2021, 12:57

Created issue #2107 to track this problem.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 59 guests