开发者

Wix CustomAction update UI?

If I have a managed Wix Custom Action, is there anyway I can u开发者_C百科pdate 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.


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&amp;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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜