Kyl*_*yle 1 controls custom-action wix
如果我有一个托管的Wix自定义操作,是否仍然可以用文本类型更新控件?我看到可以使用session.Message with 来更新进度条InstallMessage.Progress,但是我看不到更新其他UI的方法。
我找到了一个解决方案,可以完成此任务,而无需过渡对话框即可对其进行更新。
在您的自定义操作中,设置一个属性。在下面,我设置INSTALLFOLDER:
[CustomAction]
public static ActionResult SpawnBrowseFolderDialog(Session session)
{
session.Log("Started the SpawnBrowseFolderDialog custom action.");
try
{
Thread worker = new Thread(() =>
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.SelectedPath = session["INSTALLFOLDER"];
DialogResult result = dialog.ShowDialog();
session["INSTALLFOLDER"] = dialog.SelectedPath;
});
worker.SetApartmentState(ApartmentState.STA);
worker.Start();
worker.Join();
}
catch (Exception exception)
{
session.Log("Exception while trying to spawn the browse folder dialog. {0}", exception.ToString());
}
session.Log("Finished the SpawnBrowseFolderDialog custom action.");
return ActionResult.Success;
}
Run Code Online (Sandbox Code Playgroud)
在Product.wxs文件中,确保Publish将属性返回到UI,以获取要更新的编辑框:
<Control Id="FolderEdit" Type="PathEdit" X="18" Y="126" Width="252" Height="18" Property="INSTALLFOLDER" Text="{\VSI_MS_Sans_Serif13.0_0_0}MsiPathEdit" TabSkip="no" Sunken="yes" />
<Control Id="BrowseButton" Type="PushButton" X="276" Y="126" Width="90" Height="18" Text="{\VSI_MS_Sans_Serif13.0_0_0}B&rowse..." TabSkip="no">
<Publish Event="DoAction" Value="SpawnBrowseFolderDialog"><![CDATA[1]]></Publish>
<Publish Property="INSTALLFOLDER" Value="[INSTALLFOLDER]"><![CDATA[1]]></Publish>
</Control>
Run Code Online (Sandbox Code Playgroud)
因此,换句话说,您执行操作,然后必须将属性发布回自身,以调用控件中的更新。