我在选择树控件中有三个功能。我希望独立选择和安装功能 2 和 3,但如果选择安装功能 1,我希望自动选择功能 2,因为功能 1 依赖于它。当我的选择树显示时,我看到:
[-] All Features
[x] Feature 1 (requires Feature 2)
[x] Feature 2
[x] Feature 3
其中 [-] 代表“将安装在本地硬盘上”的图标,[x] 代表“整个功能将不可用”的图标。
当我选择要安装的功能 1 时,我看到:
[-] All Features
[-] Feature 1 (requires Feature 2)
[x] Feature 2
[x] Feature 3
但是当我选择功能 1 时,我希望自动选择功能 2,所以它看起来像这样:
[-] All Features
[-] Feature 1 (requires Feature 2)
[-] Feature 2
[x] Feature 3
我不想自动选择功能 3,因为功能 1 不需要它。有没有办法做到这一点?这似乎是一个简单的问题,但我找不到任何有关如何执行此操作的文档或示例。我尝试在 Feature2 中使用如下条件,但由于只选择了 Feature 1,因此从未测试过该条件:
<Feature Id="ProductFeature" Title="All Features" Display="expand" Level="1">
<Feature Id="Feature1" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 1 (requires Feature 2)" Level="2">
<ComponentRef Id="file1.txt" />
</Feature>
<Feature Id="Feature2" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 2" Level="2">
<ComponentRef Id="file2.txt" />
<Condition Level="1">MsiSelectionTreeSelectedFeature="Feature1"</Condition>
</Feature>
<Feature Id="Feature3" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 3" Level="2">
<ComponentRef Id="file3.txt" />
</Feature>
</Feature>
如果只选择了功能 1,有没有办法“告诉它”将功能 2 的级别属性设置为 1,以便选择树中的功能 2 显示图标,表明它也将被安装?如果尝试设置 Feature2 的 Level 属性不是正确的方法,是否有另一种方法可以用来完成我想要的行为?
如果您想尝试,这是我的完整程序:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="41788c15-290e-426f-934e-e5b3bf875013" Name="WixUI_FeatureTree"
Language="1033" Version="1.0.0.0" Manufacturer="WixUI_FeatureTree"
UpgradeCode="5f5d4f80-96f5-4060-a718-539b547d8a29">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<?define FeatureTree=1?>
<UIRef Id="MyWixUI_FeatureTree" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONFOLDER" Name="WixUI_FeatureTree">
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="APPLICATIONFOLDER">
<Component Id="file1.txt" Guid="FEBD6C0C-1BDF-413C-B7B1-A4E18AC7A6FA">
<File Id="file1.txt" Source="file1.txt" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="file2.txt" Guid="FEBD6C0C-1BDF-413C-B7B1-A4E18AC7A6FB">
<File Id="file2.txt" Source="file2.txt" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="file3.txt" Guid="FEBD6C0C-1BDF-413C-B7B1-A4E18AC7A6FC">
<File Id="file3.txt" Source="file3.txt" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<Feature Id="ProductFeature" Title="All Features" Display="expand" Level="1">
<Feature Id="Feature1" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 1 (requires Feature 2)" Level="2">
<ComponentRef Id="file1.txt" />
</Feature>
<Feature Id="Feature2" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 2" Level="2">
<ComponentRef Id="file2.txt" />
<Condition Level="1">MsiSelectionTreeSelectedFeature="Feature1"</Condition>
</Feature>
<Feature Id="Feature3" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 3" Level="2">
<ComponentRef Id="file3.txt" />
</Feature>
</Feature>
</Product>
</Wix>