I can’t seem to find a way to detect when a panel finishes loading. I’m adding a couple features to an already existing WPF/Prism project. I need to get called back when the page finishes rendering. I tried this:
In the UserControl at the top of the XAML that I need to get called back on when the page loads:
<UserControl x:....
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
...>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding DoSomething}" />
</i:EventTrigger>
</i:Interaction.Triggers>
Then in the code behind file:
public void DoSomething(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("received callback");
}
It currently does not work and I was not sure if this is the right path or not since I’m new to WPF, prism, and .NET.
Well I see you already know the answer… anyway…
What you did wrong you had been binding event to command in your XAML and you didn’t have command ๐ Basicly you messed up standard “code-behind approach” with let’s say “MVVM approach”/binding.
So when you touched the code-behind and created your
DoSomethingEventHandlerthere you could simplywith your CodeBehind:
It would be fine… but it’s not MVVM :]
Well and to your new approach (no code-behind/let’s say MVVM)…
If you use Prism v4.1 you can look here this feature most people miss in Prism ๐ but there is solution mentioned ๐
Well as you know you need
ICommandyou are binding to… It does not have to beDelegateCommandyou can use what you want… (I prefer and useRelayCommand)Well but what we learned from aforementioned link?
ICommandcan change Controls enabled state and it’s not updated when you don’t usePrism's Interactivityand you simply useBlend SDK's Interactivity… You don’t need it this time… I admit… but maybe some day ๐So the best you can do is this:
and your ViewModel for example:
Sorry that I unswered already answered question, but I thought I might add some interesting info ๐