4

I have a Burn Bundle with the following variable

<Variable Name="INSTALLFOLDER" Type="string "Value="[ProgramFilesFolder]" />

With the following property in my bootstrapper UI project's main view model

 public string InstallDirectory
    {
        get
        {
            if (_Engine.StringVariables.Contains("INSTALLFOLDER"))
                return _Engine.StringVariables["INSTALLFOLDER"];
            return string.Empty;
        }
        set
        {
            if (_Engine.StringVariables.Contains("INSTALLFOLDER"))
            {
                _Engine.StringVariables["INSTALLFOLDER"] = value;
                OnPropertyChanged("InstallDirectory");
            }
        }
    }

In my WPF view which has a textbox bound to the InstallDirectory property I only see "[ProgramFilesfolder]" but I was hoping to see something like "C:\Program Files"

I would like to end up with something like the following which will populate my install directory textbox with the default install folder and give the user the option to change it there.

<Variable Name='INSTALLFOLDER' Type='string' Value='[ProgramFilesFolder]$(var.AppName)' />

I could use the Net Framework to get the program files folder for my WPF UI but seems like I should be able to get it from the Wix Bundle. Also the Wix log shows that I am setting the INSTALLFOLDER property from my UI.

My bootstrapper Run looks like this:

    protected override void Run()
    {
        this.Engine.Log(LogLevel.Verbose, "Run has been called on the UI application.");

        CurrentDispatcher = Dispatcher.CurrentDispatcher;
        _MainWindow = new MainWindow(new MainWindowViewModel(this));

        Engine.Detect();

        _MainWindow.Show();
        Dispatcher.Run();

        Engine.Quit(0);
    }

I have thought I might need to listen to some event on the BootstrapperApplication after which I could fire on property changed for the InstallDirectory property but haven't found anything interesting yet.

I have been through the Developer Guide book for 3.6 and it doesn't seem to address this exact issue although the final two chapters do deal with burn projects and WPF.

Paul Matovich
  • 1,496
  • 15
  • 20

1 Answers1

6

In your get method you should be able to use this to get the actual value of the property:

get
{
    if (_Engine.StringVariables.Contains("INSTALLFOLDER"))
        return _Engine.FormatString("[INSTALLFOLDER]");
    return string.Empty;
}
Dave Andersen
  • 5,337
  • 3
  • 30
  • 29
  • Wow, Thanks Dave! I have been playing with this problem on and off for a week now, and I just did not see this syntax anywhere. Looks like the actual is: _Engine.FormatString("[INSTALLFOLDER]"); – Paul Matovich Jul 30 '13 at 01:50