Search code examples
user-interfacepropertieswixwix3

Using WiX how do I disable/enable controls based on property change?


I'm having a bit of a brain melt at the moment where I have a WiX Combobox and when I change the selection I want to disable/enable other UI controls.

  <ComboBox Property="SQLAUTHTYPE">
    <ListItem Value="WindowsAuth" Text="Windows Authentication" />
    <ListItem Value="SqlAuth" Text="SQL Authentication" />
  </ComboBox>

That is when these events are triggered ...

  MSI (c) ... PROPERTY CHANGE: Modifying SQLAUTHTYPE property. Its current value is 'WindowsAuth'. Its new value: 'SqlAuth'.
  MSI (c) ... PROPERTY CHANGE: Modifying SQLAUTHTYPE property. Its current value is 'SqlAuth'. Its new value: 'WindowsAuth'.

The following UI controls are flagged as disabled when WindowsAuth is selected and enabled when SqlAuth is selected...

  <Control Type="Edit" Width="164" Height="16" X="25" Y="149" Id="SQLAccountTextbox" Property="SQLACCOUNT"
  <Control Type="Edit" Width="164" Height="16" X="190" Y="148" Id="SQLPasswordTextbox" Property="SQLPASSWORD" Password="yes" />

Solution

  • This should do it:

    <Control Type="Edit" Width="164" Height="16" X="190" Y="148" Id="SQLPasswordTextbox" Property="SQLPASSWORD" Password="yes">
        <Condition Action="enable">SQLAUTHTYPE = "SqlAuth"</Condition>
        <Condition Action="disable">SQLAUTHTYPE = "WindowsAuth"</Condition>
    </Control>