Conditional navigation in CustomUI

Jun 16, 2016 at 10:36 AM
I've adapted the CustomMSIDialog project for my installer. During the 'activation' dialog, when the user clicks next, I'd like to conditionally navigate to the next dialog.

So, if activation = 1 then go to ActivatedForm, and if activation = 0 then go to NotActivatedForm.

Not a big requirement, but was curious if this is possible within the current framework.

Thanks!
Dax
Coordinator
Jun 17, 2016 at 8:04 AM
You chosen the most complicated UI model MSI native UI :)

Because of this you are loosing any opportunity to use imperative expressions (e.g. C# code) and you will need to resort to declarative (XML) expressions that are less compatible with algorithmic tasks but more suitable for expressing relationships. That is why your task would be extremely simple is done with ManagedUI (C#) with simple code as this
void next_Click(object sender, EventArgs e)
{
    int index = Shell.Dialogs.IndexOf(ActivatedForm);
    if (activation == 0)
        index = Shell.Dialogs.IndexOf(NoActivatedForm);
    Shell.GoTo(index);
}
With WiX you will need to have something like this:
...
<Publish Dialog="ProductActivationForm" Control="Next" Event="NewDialog" Value="ActivatedForm" Order="1">activation = "1"</Publish>
<Publish Dialog="ProductActivationForm" Control="Next" Event="NewDialog" Value="NotActivatedForm" Order="2">activation = "2"</Publish>
<Publish Dialog="ProductActivationForm" Control="Cancel" Event="EndDialog" Value="Exit">1</Publish>
In Wix# you will achieve this with something like this:
customUI.On(activationDialog, Buttons.Next, new ShowDialog(NativeDialogs.ActivatedForm, "activated = \"1\""),
                                            new ShowDialog(NativeDialogs.NotActivatedForm, "activated = \"0\""));
But the you will also need to implement your ActivatedForm/NotActivatedForm dialogs. Not an easy task...

I stopped and Wix# evolution towards native MSI UI as it can deliver very little benefit comparing to WiX. Still messy, non-intuitive and hard to maintain. Wix# ManagedUI (interface for MSI/WiX EnbeddedUI model) seems to fit much better for the task. But... if you have to use MSI UI... then prepare yourself for some fight :)
Jun 23, 2016 at 12:35 PM
Haha. I guess I was missing the undue complications of MSI. :D You're right, this may be overkill.

Thank you for the code - I will definitely keep it in my library for potential usage. For now, I decided to make two sets of controls in the same form and show them conditionally.

We were using the Managed UI but while testing, we found inconsistencies in the UI on high DPI systems. These are old, known issues with Windows Forms. So for now we will use MSI and in the future use a WPF interface.

Thanks for your help! :)