如何设置WiX中UI控件的默认值?

发布于 2024-11-08 20:49:33 字数 615 浏览 0 评论 0原文

如何在 WiX 安装程序中设置 UI 控件的默认值? 当我更改控件中的值时,更改将传播到属性。但我希望在首次显示对话框时设置一些特定值。

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <Property Id="PORT" Value="8731" />
    <UI>
      <Dialog Id="MyDialog" Width="370" Height="270" Title="Service protocol configuration">
        <!-- ... -->
        <Control Type="Edit" Id="PortEdit" Width="52" Height="15" X="79" Y="68" Text="8731" Property="PORT" Integer="yes" />
      </Dialog>
    </UI>
  </Fragment>
</Wix>

How can I set the default value of a UI control in WiX installer?
When I change the value in the control, the changes are propagated to the property. But I want some specific value to be set when the dialog is first displayed.

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <Property Id="PORT" Value="8731" />
    <UI>
      <Dialog Id="MyDialog" Width="370" Height="270" Title="Service protocol configuration">
        <!-- ... -->
        <Control Type="Edit" Id="PortEdit" Width="52" Height="15" X="79" Y="68" Text="8731" Property="PORT" Integer="yes" />
      </Dialog>
    </UI>
  </Fragment>
</Wix>

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

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

发布评论

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

评论(2

病毒体 2024-11-15 20:49:33

您可以将 Indirect="yes" 添加到您的控件定义中,之后该控件将显示您的属性值,并且对控件的所有更改将立即更改您的属性。

例如,

  <Dialog Id="InstallDirDlgMine" Width="370" Height="270" Title="!(loc.InstallDirDlgMine_Header)">
...
    <Control Id="Folder" Type="PathEdit" X="135" Y="72" Width="230" Height="20" Property="WIXUI_INSTALLDIR" Indirect="yes" />
...
  </Dialog>

you may add Indirect="yes" to yout control definition, after that control will display your property's value and all changes to control will change your property immideately.

for example,

  <Dialog Id="InstallDirDlgMine" Width="370" Height="270" Title="!(loc.InstallDirDlgMine_Header)">
...
    <Control Id="Folder" Type="PathEdit" X="135" Y="72" Width="230" Height="20" Property="WIXUI_INSTALLDIR" Indirect="yes" />
...
  </Dialog>
最终幸福 2024-11-15 20:49:33

这似乎对我有用(Indirect="yes" 不起作用)。当该对话框显示时,控件在框中显示该值作为其值。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
    <Property Id="MYPROPERTY" Value="Show this value in the box" />

    <UI>
      <Dialog Id="MyIdDlg" Width="370" Height="270" Title="My Title">
        <!-- omitted --> 
        <Control Id="MyId" Type="Edit" X="20" Y="100" Width="320" Height="18" Property="MYPROPERTY" />
      </Dialog>
    </UI>
    </Fragment>
</Wix>

This seemed to work for me (Indirect="yes" didn't work). When that dialog was shown, the control had Show this value in the box as its value.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
    <Property Id="MYPROPERTY" Value="Show this value in the box" />

    <UI>
      <Dialog Id="MyIdDlg" Width="370" Height="270" Title="My Title">
        <!-- omitted --> 
        <Control Id="MyId" Type="Edit" X="20" Y="100" Width="320" Height="18" Property="MYPROPERTY" />
      </Dialog>
    </UI>
    </Fragment>
</Wix>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文