2013-06-14 12 views
0

사용자 지정 작업을 사용하여 값을 채우려 고 값을 product.wxs 안에있는 콤보 상자에 바인딩하려고합니다.WIX 콤보 박스 바인딩 값

콤보 상자 안의 국가 목록을 채우려면 값을 바인딩하는 방법을 안내해 줄 수 있습니까?

내 MSI 설정을 실행하는 동안 값이 combox 안에 표시되도록이 값을 전달하는 방법에 어려움을 겪고 있습니다.

public static ActionResult FillList(Session xiSession) 
    { 

     Dictionary<string, string> _co = new Dictionary<string, string>(); 
     _co.Add(String.Empty, String.Empty); 
     _co.Add("US", "United States"); 
     _co.Add("CA", "Canada"); 
     _co.Add("MX", "Mexico"); 

     xiSession.Log("Return success"); 
     return ActionResult.Success; 
    } 

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 
    <MediaTemplate /> 

    <Feature Id="ProductFeature" Title="SetupProjectComboTest" Level="1"> 
     <ComponentGroupRef Id="ProductComponents" /> 
    </Feature> 

<UI> 
    <UIRef Id="WixUI_Mondo" /> 

    <Dialog Id="MyCustomDlg" Width="500" Height="260"> 
    <Control Id="ComboBoxMain" Type="ComboBox" X="10" Y="60" Width="300" Height="17" Property="COUNTRIES" /> 
    <Control Id="ButtonMain" Type="PushButton" X="320" Y="60" Width="40" Height="17" Text="Show"> 
     <Publish Property="COMBOVALUEFORMATTED" Order="1" Value="[COUNTRIES]" /> 
    </Control> 
    <Control Id="LabelMain" Type="Text" X="10" Y="80" Width="360" Height="17" Property="COMBOVALUEFORMATTED" Text="[COMBOVALUEFORMATTED]" /> 

    </Dialog> 
</UI> 
:

다음은 내가 애 쓰고 코드를 제공

답변

2

<Fragment> 
    <Directory Id="TARGETDIR" Name="SourceDir"> 
     <Directory Id="ProgramFilesFolder"> 
      <Directory Id="INSTALLFOLDER" Name="SetupProjectComboTest" /> 
     </Directory> 
    </Directory> 
</Fragment> 

<Fragment> 
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> 
     <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. --> 
     <!-- <Component Id="ProductComponent"> --> 
      <!-- TODO: Insert files, registry keys, and other resources here. --> 
     <!-- </Component> --> 
    </ComponentGroup> 
</Fragment> 

당신은 목록 값을 바인딩 콤보 테이블에 행을 삽입해야합니다. ORCA Editor에서 msi를 열면 msi 테이블과 행을 찾을 수 있습니다.

msi에서 다른 ComboBox 요소를 사용하지 않는 경우 EnsureTable 요소를 포함해야합니다.

<EnsureTable Id="ComboBox"/> 

사용자 지정 작업에서 행을 삽입 할 수 있습니다.

static int intex = 1; 
public static void FillComboBox(Session session, string text, string value) 
    { 
     View view = session.Database.OpenView("SELECT * FROM ComboBox"); 
     view.Execute(); 

     Record record = session.Database.CreateRecord(4); 
     record.SetString(1, "COUNTRIES"); 
     record.SetInteger(2, intex); 
     record.SetString(3, value); 
     record.SetString(4, text); 

     view.Modify(ViewModifyMode.InsertTemporary, record); 
     view.Close(); 
     intex++; 
    } 

사용자 지정 동작 내에서 FillComboBox 메서드를 호출하십시오.

public static ActionResult FillList(Session xiSession) 
    { 

     FillComboBox(xiSession, "US", "United States"); 
     FillComboBox(xiSession, "CA", "Canada"); 
     FillComboBox(xiSession, "MX", "Mexico");   

     return ActionResult.Success; 
    } 

은 실행하는 것이 콤보 상자 대화하기 전에 에서 InstallUISequence에서 사용자 지정 작업을 실행합니다.

<InstallUISequence> 
    <Custom Action="INSERT_ROWS" After="AppSearch">Not Installed</Custom> 
    </InstallUISequence> 
+0

감사합니다. 당신의 예제를 기반으로했는데 지금은 콤보 상자가 가치를 바인딩하는 데 사용하고 있습니다. 제가 알고 싶습니다. 콤보 상자에 기본값을 표시하는 방법을 알고 싶습니다. - 선택 -. – reapen

+0

기본값을 COUNTRIES 속성으로 설정해야합니다. 양식 Wix <속성 ID = "국가"값 = "미국"/> 또는 사용자 지정 작업 xiSession [ "COUNTRIES"] = "미국"; – Vinoth

+0

답장을 보내 주셔서 감사합니다. 답장을 보내 주셔서 감사합니다. 예를 들어 – reapen