tibel / Caliburn.Light

The magic-free Caliburn.Light, a powerful framework designed for building applications across current XAML platforms.
MIT License
68 stars 7 forks source link

How to pass command parameter for some custom event in UAP? #75

Closed belyansky closed 8 years ago

belyansky commented 8 years ago

After update to the latest version of Caliburn.Light I faced with some changes of the framework. For example there is no EventTrigger class. So the code from below doesn't compiles anymore.

<Frame x:Name="RootFrame">
    <i:Interaction.Behaviors>
        <light:EventTrigger EventName="Loaded">
            <light:EventTrigger.Actions>
                <light:InvokeCommandAction
                    Command="{Binding SetupNavigationServiceCommand}"
                    CommandParameter="{Binding ElementName=RootFrame}" />
            </light:EventTrigger.Actions>
        </light:EventTrigger>
    </i:Interaction.Behaviors>
</Frame>

Are there any new out of the box alternatives which can help to rewrite this code? How can I pass command parameter?

tibel commented 8 years ago

Bahavior SDK was removed for v3 with #69. With this change EventTrigger, InvokeCommandAction and CallMethodAction are no longer supported for Windows 10 UAP projects.

There are two reasons behind this:

I know there is a feature gap at the moment in v3 UAP that I hope to close in the next weeks.

Back to you question: With x:Bind you would write it Loaded="{x:Bind Model.SetupNavigationServiceCommand.OnEvent}". Unfortunately that will not work for the Loaded event because it's not a routed event (the event args don't contain the source element). At the moment you have to fall back to code behind and call your commands Execute(parameter) method from there. Another possibility is to use InvokeCommandAction from Behaviors SDK directly.

belyansky commented 8 years ago

Thanks for your answer.