Wix CustomAction 更新 UI?

发布于 2024-10-17 13:13:25 字数 146 浏览 0 评论 0原文

如果我有一个托管的 Wix 自定义操作,我是否可以使用文本类型更新控件?我发现可以通过使用 session.MessageInstallMessage.Progress 来更新进度栏,但我没有看到更新其他 UI 的方法。

If I have a managed Wix Custom Action, is there anyway I can update a Control with the type of Text? I see that a progress bar can be updated by using the session.Message with InstallMessage.Progress, but I do not see a way for updating other UI.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦断已成空 2024-10-24 13:13:25

我找到了一个解决方案来完成此任务,而无需转换对话框即可更新。

在您的自定义操作中,设置一个属性。下面,我设置了 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;
}

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>

换句话说,您执行该操作,然后必须将该属性发布回其自身以调用控件中的更新。

I found a solution to get this done without having to transition dialogs in order to get it to update.

In your custom action, set a property. Below, I set 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;
}

In your Product.wxs file, make sure to Publish the property back to the UI in order to get edit boxes to update:

<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>

So in other words, you do the action, then you must publish the property back onto itself to invoke an update in the control.

半窗疏影 2024-10-24 13:13:25

对于文本控件,您可以使用括在方括号中的属性: [SOMEPROP]

然后在您的 CA 中您可以说 session["SOMEPROP"] = "somevalue"。注意 MSI 在刷新 UI 方面不太稳定,因此您几乎必须从一个对话框转换到另一个对话框才能使其正常工作。换句话说,在上一个对话框的下一个按钮上调用 CA,并且在下一个对话框中文本控件将显示文本。

For a text control you can use a property wrapped in brackets: [SOMEPROP]

Then in your CA you can say session["SOMEPROP"] = "somevalue". Note MSI is wonky about refreshing the UI so you'll pretty much have to transition from one dialog to another to get this to work. In other words, on the next button of the previous dialog call the CA and in the next dialog the text control will display the text.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文