I subscribed to the wpf window. Loaded event: Loaded += loaded;and try to change the opacity of some controls in the code. I noticed that in the method the loadedcontrols are not yet colored by wpf. Thus, the code does not work, the rendering of controls occurs only after the method exits.
1) Is there another event, for example. RenderedI can subscribe to?
EDIT: I just discovered that there is an OnContentRendered event, and the following code works:
Although animation is probably preferable.
protected override void OnContentRendered(EventArgs e)
{
base.OnContentRendered(e);
for (int i = 0; i < 100; i++)
{
Parentpanel.Opacity += 0.01;
Splashscreen.Opacity -= 0.01;
Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.ContextIdle, null);
Thread.Sleep(50);
}
}
Otherwise, I probably have to use an animation that changes the opacity of usercontrol1 from 0.1 to 1.0 and usercontrol2 from 1.0 to 0.0.
2) Do you know an example of such an animation?