Home > other >  WPF Localization problem with MDIX DialogHost
WPF Localization problem with MDIX DialogHost

Time:12-27

I am using the MaterialDesignInXAML and handling localization with Infralution.Localization.Wpf Resx extension. All works fine, but I noticed that when I use a DialogHost, all the controls in DialogContent tag to not get localized. the ones outside it are well localized.

Example :

<materialDesign:DialogHost DialogTheme="Inherit">
            <materialDesign:DialogHost.DialogContent>
                        <Label Height="32" FontSize="22" FontFamily="Fonts/#Cooper Black" Foreground="#FFCBDAD1" HorizontalAlignment="Left"  VerticalAlignment="Top" Content="{Resx Hello_Word}" TabIndex="2" Margin="87,45,0,0">
            <materialDesign:DialogHost.DialogContent>
                        <Label Height="32" FontSize="22" FontFamily="Fonts/#Cooper Black" Foreground="#FFCBDAD1" HorizontalAlignment="Left"  VerticalAlignment="Top" Content="{Resx Hello_Word}" TabIndex="2" Margin="87,45,0,0">
</materialDesign:DialogHost>

Here the second label will display the localized string, but the one inside DialogContent will just display "#Hello_Word"

How can I fix it ?

CodePudding user response:

I finally found a workaround. I create an invisible control outside the DialogContent, and I bind its content/text to the one inside DialogContent

<materialDesign:DialogHost DialogTheme="Inherit">
            <materialDesign:DialogHost.DialogContent>
                        <Label Height="32" FontSize="22" FontFamily="Fonts/#Cooper Black" Foreground="#FFCBDAD1" HorizontalAlignment="Left"  VerticalAlignment="Top" Content="{Binding ElementName=h1, Path=Content}" TabIndex="2" Margin="87,45,0,0">
            <materialDesign:DialogHost.DialogContent>
                        <Label Name="h1" Visiility="Hidden" Content="{Resx Hello_World}" >
</materialDesign:DialogHost>
  • Related