根据 属性 值显示不同的图像

Show different images based on property value

我想做以下事情:

<Image X="0" Y="0" Width="20" Height="20" ImageFile="[Status].bmp" />

其中 Status 是一个变量。目前这不起作用,因为 ImageFile 属性的内容似乎没有展开。

我实现了自定义 bafunctions.dll,但找不到如何通过 IBootstrapperEngine 访问控件。

有什么建议吗?

在 WiX v4 中,您可以这样做:

<ImageControl X="0" Y="0" Width="20" Height="20" ImageFile="Status1.bmp"
              VisibleCondition="Status = Status1" />
<ImageControl X="0" Y="0" Width="20" Height="20" ImageFile="Status2.bmp"
              VisibleCondition="Status = Status2" />

不过,页面不会自动刷新。您可能必须使用

ThemeShowPageEx(pTheme, pTheme->dwCurrentPageId, SW_SHOW, THEME_SHOW_PAGE_REASON_REFRESH);

在 WiX v3 中,不支持执行此操作的方法。 bafunctions.dll 需要访问 THEME 但 WixStdBA 在 v3 中没有提供。我想您理论上可以获取顶层 window 并枚举所有子控件,直到找到要显示或隐藏的正确控件,并将它们最初设置为不可见。

 <Image X="0" Y="0" Width="20" Height="20" ImageFile="Status1.bmp" Visible="no />
 <Image X="0" Y="0" Width="20" Height="20" ImageFile="Status2.bmp" Visible="no />