Animation for displaying and then collapsing a UserControl is not working
Posted: 21 May 2019, 13:46
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