Wpf. Prism. Interaction of elements in different regions
-
Working with Prism regions has faced the problem of the complementarity of elements.
More specific.
- This is RegionMain
- Some element with Element
Animation begins when applied to the button. Code:
<Button Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Width="95" HorizontalAlignment="Left"> <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Element" From="0.0" To="1.0" Duration="0:0:1"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers>
If the region ' s contents move to form, there will be no error and animation will work, and if the region leaves a mistake:
Additional information: Can't find the name "Element" in "System.Windows.Controls.Button."
How do you start animating the element from another region?
-
Let me try analogy. You have a local variable in one function. You smashed this function for two smaller, the local variable stayed in one piece. Now somehow the code in another piece, referring to this most local variable, has stopped working.
You're doing wrong. You don't want one piece of code to run another.
Put animation to the element where this animation occurs. Since you're using Prism, you can't get past MVM. Which means that UI-events should not be managed by other UI events, but by tied data.
Let the button, like she should, send a team to VM. The role of the region with the button ends.
Region number two, let's monitor the data and launch animation when necessary. Like, it could be.
DataTrigger
♪Regions must interact differently through VM. That's what you're gonna reduce the UI-code connection.