Ioa*_*nis 8 user-interface controls wix conditional-statements
我在wix中创建了一个自定义对话框页面,它有一个文本框.如果文本框为空,我想禁用安装程序的下一个按钮如果用户键入了值,则启用它.以下代码部分工作.它不会禁用下一个按钮,但除非您填写该值,否则它不会导航到下一页.我遇到的问题是,当您在编辑文本框中键入值时,不会更新下一个按钮的状态.如果我从编辑文本框中删除该值,然后单击返回上一个屏幕,然后单击下一步,则禁用下一个按钮.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="MyCustomDialog" Width="370" Height="270" Title="Custom Dialog Options">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
<Condition Action="disable">USERNAME1 = ""</Condition>
<Condition Action="enable">NOT(USERNAME1 = "")</Condition>
<Publish Event="NewDialog" Value="VerifyReadyDlg">NOT(USERNAME1 = "")</Publish>
</Control>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back">
<Publish Event="NewDialog" Value="CustomizeDlg">1</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please type the value" />
<Control Id="UserNameText" Type="Text" X="20" Y="60" Width="290" Height="13" NoPrefix="yes" Text="Please type the username" />
<Control Id="UserNameEdit" Type="Edit" X="20" Y="72" Width="290" Height="18" Multiline="no" Property="USERNAME1"/>
</Dialog>
</UI>
</Fragment>
</Wix>
Run Code Online (Sandbox Code Playgroud)
小智 7
在WIX中几乎不可能禁用和启用"下一步"按钮.来自@ Wjdavis5的答案为我禁用了"下一步"按钮,但只有当用户点击另一个文本框时,该按钮才会启用.这令人困惑.
以下代码基于此答案.它显示单个文本输入框,当用户单击"下一步"时,它会显示错误对话框,或进入安装屏幕.
<Dialog Id="UserRegistrationDialog" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="UserIdEdit" Type="Edit" X="45" Y="85" Width="220" Height="18" Property="UserID" Text="{80}" />
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next" >
<Publish Event="NewDialog" Value="VerifyReadyDlg">2</Publish>
<Publish Event="SpawnDialog" Value="UserIdError"><![CDATA[UserID = ""]]></Publish>
</Control>
</Dialog>
<Dialog Id="UserIdError" Width="260" Height="85" NoMinimize="no" Title="[ProductName]">
<Control Id="UserIdErrorDesc" Type="Text" Width="194" Height="30" X="48" Y="15" Text="Please enter a User ID." />
<Control Id="UserIdErrorOk" Type="PushButton" X="97" Y="57" Width="56" Height="17" Text="Ok">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
</Dialog>
Run Code Online (Sandbox Code Playgroud)
这是我如何做到的。
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&Next">
<Condition Action="enable"><![CDATA[InDBCONNECTION_STRING_VALID = "1"]]></Condition>
<Condition Action="disable"><![CDATA[InDBCONNECTION_STRING_VALID = "0"]]></Condition>
</Control>
Run Code Online (Sandbox Code Playgroud)