Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set title and description for CustomDialogWith<T> #1491

Closed
anv1l opened this issue Apr 4, 2024 · 14 comments
Closed

How to set title and description for CustomDialogWith<T> #1491

anv1l opened this issue Apr 4, 2024 · 14 comments

Comments

@anv1l
Copy link

anv1l commented Apr 4, 2024

Most likely silly question but... well, the title says it all. Now I just get the default placesholder values.

@Torchok19081986
Copy link

Hallo, you have some options here. Short : if you use the Custom UI you have access to each Dialog and here you can just replace Placeholder to your string Title, thats it.

Long Version : Each Dialog , if it WPF and C#, can be bound to Property of Title and UI / View map Title to Property and you can only change this Property and your Titlename will be change automatically. In Template of Wix# WPF C# Oleg use Caliburn.Micro Framework.
If you new to this type, check MVVM Tutorials and i can only recommended also look for CommunityToolKit.MVVM from MS. Is easy , nice to handle and for beginner easier to understand.

Some Link for MVVM :

  1. https://learn.microsoft.com/de-de/dotnet/communitytoolkit/mvvm/
  2. https://caliburnmicro.com/ (out of support anymore.)
  3. https://docs.prismlibrary.com/docs/

and for learn https://www.tutorialspoint.com/mvvm/index.htm, for understanding.

Best regards, Torchok.

@anv1l
Copy link
Author

anv1l commented Apr 5, 2024

Yes, this can be done when you inherit from WpfDialog. What I am curious is how this can be done when you don't use that, for example in sample CustomUIDialog.WPF with CustomDialogPanel : UserControl, IWpfDialogContent.

@Torchok19081986
Copy link

Torchok19081986 commented Apr 5, 2024

just looked myself tosample CustomUIDialog.WPF. Example use already MVVM Framework. This is Caliburn.Micro. You can create string Property and bind Title to it.

private stirng _title;

public string TitleText
{
    get { return _title; }
    set
    {
         _title = value;
    }
}

in C# code and add into UserControl TextBlock on top of him something like TextBlock Text = "{Binding TitleText }". Has to be something like this, because usercontrol doesnt has property Title like WPF Window.

@anv1l
Copy link
Author

anv1l commented Apr 5, 2024

I can bind wpf elements, but the title and description comes from managed form host?

@Torchok19081986
Copy link

and may i ask, why you want to use usercontrols for WPF UI and not standard WPF UI from Template of Wix# ?

@anv1l
Copy link
Author

anv1l commented Apr 5, 2024

So from that sample. The user control part is wpf, which works as expected.

image

No other particular reason, other than following the more simple implementation from samples. But looks like it's not really an option.

@Torchok19081986
Copy link

AFAIK oleq self suggest always to use Custom UI Template of v3 or V4 for WPF if you want to maximaze your flexibility for build UI and MSI, whatever you want Bootstrapper Application or MSI embeded in it. I had near ~90% installers with template and this works always.

@anv1l
Copy link
Author

anv1l commented Apr 5, 2024

Yeah, seems so. However, if you are left with above default texts, the sample is not really usable in any scenario, might be an idea to just remove it.

@Torchok19081986
Copy link

maybe. But for some unknown reason, @oleg-shilo created it and add it to samples.

@oleg-shilo
Copy link
Owner

You can always use VS templates to have the dialogs source. Then you can just modify them and even remove Caliburn autobinding completely.

This is how autobiding implemented now. It's dome entirely from XAML:
image
Because the text block content is enclosed in square brackets. WixSharp knows that it needs to treat the bracketed content as n MSI property name and resolve it.

If ou prefer to set it manually you simply give the TextBlock name in XAML and then set its value from codebehid:

<TextBlock
    x:Name="titleLabel"
    Grid.RowSpan="1"
    Grid.Column="1"
    Margin="10,25,10,10"
    VerticalAlignment="Top"
    Background="White"
    FontSize="16"
    FontWeight="Normal"/>

and then in WelcomeDialog.xaml.cs:

public WelcomeDialog()
{
    InitializeComponent();
    titleLabel.Text = "whatever";
}

This is now just a generic WPF routine.

@anv1l
Copy link
Author

anv1l commented Apr 5, 2024

Thanks for input. If you put this in the context of sample CustomUIDialog.WPF / CustomDialogPanel.xaml how do you change the marked texts, that come from windows forms host I believe.

image

@oleg-shilo
Copy link
Owner

@anv1l, the code sample you are asking about specifically demonstrates how to provide minimalistic content of a custom dialog without changing any UI elements shared with other dialogs (e.g. dialog title or description label).

And yet it is exactly what you are trying to do - customize that shared content. That's you are much better off by using the custom UI VS template where you have access to all UI elements including the ones that you specifically mentioned (title and description label).

@anv1l
Copy link
Author

anv1l commented Apr 9, 2024

I am not sure if I could have been more clear; it's in the issue topic already. I was only asking if the title and description could be changed when using CustomDialogWith (as used in the samples). That's all.

I did not think it would make sense to have that feature without being able to change those values and assumed you could change them somehow - and avoid modifying my installer solution to work with WpfDialog.

@anv1l anv1l closed this as completed Apr 9, 2024
@oleg-shilo
Copy link
Owner

oleg-shilo commented Apr 9, 2024

Appologies, I indeed misunderstood what you are trying to do.

And indeed the sample were discussing does not explain how to control the localization of the custom dialog content.

What you need to do is to add the new content to the localization data. Either with the WXL file or dynamically at runtime.

project.UIInitialized += e =>
{
    // Since the default MSI localization data has no entry for 'CustomDlgTitle' (and other custom labels) we
    // need to add this new content dynamically. Alternatively, you can use WiX localization files (wxl).

    MsiRuntime runtime = e.ManagedUI.Shell.MsiRuntime();

    runtime.UIText["CustomDlgTitle"] = "My Custom Dialog";
    runtime.UIText["CustomDlgTitleDescription"] = "My Custom Dialog Description";
};

I have updated the sample to reflect on how to do that:

image

oleg-shilo added a commit that referenced this issue May 1, 2024
- #1503: %AppData% folder no replace by path wix4
- #1493: Question : Make Wix# Wix Toolset v5 compatible
- #1491: How to set title and description for CustomDialogWith&lt;T&gt;
- #1310: Problem during dynamic localization
- Enhancement #1497: MSI language
- Improved algorithm for locating compatible version of installed WiX extension file.
- Added extension method for reading localized strings from wxl files:   `product.LocalizationFile.GetLocalizedString("ProductName")`</releaseNotes>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants