gpt4 book ai didi

Wix 与条件、属性和自定义操作的交互

转载 作者:行者123 更新时间:2023-12-03 21:27:00 26 4
gpt4 key购买 nike

我在设置对话框上按钮的启用状态时遇到问题。有问题的按钮定义为:

<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
<Condition Action="disable">Validated = 0</Condition>
<Condition Action="enable"><![CDATA[Validated <> 0]]></Condition>
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>

属性 Validated 的初始值是 0,正如预期的那样,下一个按钮开始被禁用。
<Property Id="Validated" Value="0"/>

属性本身是通过另一个按钮上的自定义操作修改的。
<Control Id="PerformValidation" Type="PushButton" X="225" Y="75" Width="50" Height="20" Text="Validate">
<Publish Event="DoAction" Value="ValidateDB">1</Publish>
</Control>

使用精简版的自定义操作,例如:
[CustomAction]
public static ActionResult ValidateDatabase(Session session)
{
session.Log("Begin ValidateDatabase");
session["Validated"] = "1";
return ActionResult.Success;
}

我面临的问题是,在自定义操作运行后,下一步按钮不会重新启用。我可以确认 CA 确实运行了,并且该属性已成功设置。如果我执行一些其他操作导致它刷新,UI 将更新,例如返回一个页面然后再次前进到这个页面,下一步按钮将被启用。

关于如何在自定义操作后刷新按钮状态的任何想法?

最佳答案

http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg05097.html提供了一种解决方案,可以在自定义操作之后立即重新发布在自定义操作中更改的属性。

这是我如何让它在我的代码中工作的示例:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Binary Id="ConnectionStringExtension.dll" SourceFile="$(var.ConnectionStringExtension.TargetDir)$(var.ConnectionStringExtension.TargetName).CA.dll" />
<CustomAction Id="MyCustomAction" BinaryKey="ConnectionStringExtension.dll" DllEntry="VerifyConnectionString" Execute="immediate" />

<UI>
<Dialog Id="ConnectionStringDlg" Width="370" Height="270" Title="Database Settings - [ProductName]" NoMinimize="yes">
<Control Id="ConnectionStringLabel" Type="Text" X="45" Y="73" Width="100" Height="15" TabSkip="no" Text="&amp;Connection String:" />
<Control Id="ConnectionStringEdit" Type="Edit" X="45" Y="95" Width="220" Height="15" Property="CONNECTION_STRING" Text="{200}" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
<Condition Action="enable"><![CDATA[CONNECTION_STRING <> "" AND CONNECTION_STRING_VALID = "1"]]></Condition>
<Condition Action="disable"><![CDATA[CONNECTION_STRING = "" OR CONNECTION_STRING_VALID = "0"]]></Condition>
</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="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please enter database configuration</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Database Settings</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="VerifyButton" Type="PushButton" Width="56" Height="16" X="45" Y="118" Text="Verify">
<Publish Event="DoAction" Value="MyCustomAction">1</Publish>
<Publish Property="TEMP_VERIFIED" Value="[CONNECTION_STRING_VALID]">1</Publish>
<Publish Property="CONNECTION_STRING_VALID" Value="[TEMP_VERIFIED]" />
</Control>
</Dialog>
</UI>
</Fragment>
</Wix>

CustomAction 将 CONNECTION_STRING_VALID 的值设置为 1 或 0,具体取决于它是否有效,我在别处定义了默认值为 0

<Property Id="CONNECTION_STRING_VALID" Value="0" />

现在,当我单击验证按钮时,如果字符串有效,则启用下一步按钮

关于Wix 与条件、属性和自定义操作的交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4241863/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com