Animation for displaying and then collapsing a UserControl is not working
I'm trying to display my UserControl for short time when there is a change in a property value. In WPF, I used the following:
After trying this method in Noesis rendering and not getting the desired result, I tried to use a similar animation in code behind in a handler for PropertyChanged event (I've thought that perhaps NotifyOnTargetUpdated mechanism is not working in Noesis):
As it turns out, this code is working only if I stop at the beginning of the function with a breakpoint. During uninterrupted execution there is no effect.
Could you help me to find a way in Noesis to show a control and then to collapse it after certain time interval?
Thanks in advance
Code: Select all
<Grid>
<Grid.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0"
Value="{x:Static Visibility.Visible}" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.5"
Value="{x:Static Visibility.Collapsed}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<TextBlock Text="{Binding IllumData.Collimat, StringFormat={}{0,3:0}, NotifyOnTargetUpdated=True}"
FontSize="22"
Foreground="White"
Margin="134, 170, 0, 0" />
<TextBlock Text="{Binding IllumData.Flood, StringFormat={}{0,3:0}, NotifyOnTargetUpdated=True}"
FontSize="22"
Foreground="White"
Margin="20, 422, 0, 0" />
</Grid>
Code: Select all
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
Storyboard storyboard = new Storyboard();
ObjectAnimationUsingKeyFrames objAnim = new ObjectAnimationUsingKeyFrames();
Storyboard.SetTargetName(objAnim, Name);
Storyboard.SetTargetProperty(objAnim, new PropertyPath(UserControl.VisibilityProperty));
DiscreteObjectKeyFrame visibleKeyFrame = new DiscreteObjectKeyFrame();
visibleKeyFrame.KeyTime = TimeSpan.FromSeconds(0);
visibleKeyFrame.Value = Visibility.Visible;
objAnim.KeyFrames.Add(visibleKeyFrame);
DiscreteObjectKeyFrame collapsedKeyFrame = new DiscreteObjectKeyFrame();
collapsedKeyFrame.KeyTime = TimeSpan.FromSeconds(1);
collapsedKeyFrame.Value = Visibility.Collapsed;
objAnim.KeyFrames.Add(collapsedKeyFrame);
storyboard.Children.Add(objAnim);
storyboard.Begin(this);
}
Could you help me to find a way in Noesis to show a control and then to collapse it after certain time interval?
Thanks in advance
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Animation for displaying and then collapsing a UserControl is not working
Hi,
In the meantime you may want to use the interactivity PropertyChangedTrigger to fire the animation everytime the binding value changes:
Please let me know if that works.
You're right, Binding.NotifyOnTargetUpdated and Binding.TargetUpdated event are not implemented in Noesis yet. Could you please report it in our bugtracker, it sounds like an interesting feature to have in the future.I've thought that perhaps NotifyOnTargetUpdated mechanism is not working in Noesis
This is very strange, could you also report this in the bugtracker, I have no clue now what could be happening to work only if you stop in a breakpoint.As it turns out, this code is working only if I stop at the beginning of the function with a breakpoint. During uninterrupted execution there is no effect.
In the meantime you may want to use the interactivity PropertyChangedTrigger to fire the animation everytime the binding value changes:
Code: Select all
<Grid x:Name="IllumData">
<Grid.Resources>
<Storyboard x:Key="ShowIllumData">
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0"
Storyboard.TargetProperty="Visibility"
Storyboard.TargetName="IllumData">
<DiscreteObjectKeyFrame KeyTime="0:0:0"
Value="{x:Static Visibility.Visible}" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.5"
Value="{x:Static Visibility.Collapsed}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<i:Interaction.Triggers>
<i:PropertyChangedTrigger Binding="{Binding IllumData.Collimat}">
<ei:ControlStoryboardAction Storyboard="{StaticResource ShowIllumData}"/>
</i:PropertyChangedTrigger>
<i:PropertyChangedTrigger Binding="{Binding IllumData.Flood}">
<ei:ControlStoryboardAction Storyboard="{StaticResource ShowIllumData}"/>
</i:PropertyChangedTrigger>
</i:Interaction.Triggers>
<TextBlock Text="{Binding IllumData.Collimat, StringFormat={}{0,3:0}, NotifyOnTargetUpdated=True}"
FontSize="22"
Foreground="White"
Margin="134, 170, 0, 0" />
<TextBlock Text="{Binding IllumData.Flood, StringFormat={}{0,3:0}, NotifyOnTargetUpdated=True}"
FontSize="22"
Foreground="White"
Margin="20, 422, 0, 0" />
</Grid>
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 54 guests