MahApps.Metro icon indicating copy to clipboard operation
MahApps.Metro copied to clipboard

Binding on dynamicRes are not updating

Open TheCamel opened this issue 1 year ago • 8 comments

localize is not working in our app

We use strings in dictionnary and all elements are refreshed into the new strings when we change the dictionnary but not the datagrid headers (not mahapps) and the hamburger menu... Tabs are working with some other controls

Steps to reproduce

with the demo app, include the stringManager joined

and 2 dictionnaries in the folder \Resources\XAML\Languages change as resource

include one of them by default in the app.xaml

<ResourceDictionary Source="/MahApps.Metro.Demo;Component/Resources/XAML/Languages/Strings.fr-FR.xaml" />

bind a menuitem to a string in HamburgerMenuDefault.xaml

<mah:HamburgerMenuGlyphItem Glyph="/Assets/Photos/GiantSlabInOregon.png"
                            Label="{DynamicResource AdminView.LineView}" />

and bind also the tabs in HamburgerMenuSample.xaml


<TabItem Header="{DynamicResource Schedule.Auto}">
    <exampleViews:HamburgerMenuDefault DataContext="{Binding}" />
</TabItem>
<TabItem Header="{DynamicResource Schedule.Manu}">
    <exampleViews:HamburgerMenuCreatorsUpdate DataContext="{Binding}" />
</TabItem>

in the app start call to change the culture from FR to US

protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);
    StringManager.Instance.SetCulture("en-US");
}

bind a command in the menu to change back

this.ShowProgressDialogCommand = new SimpleCommand<object>(o => true, x => StringManager.Instance.SetCulture("fr-FR") ); //this.RunProgressFromVm()

work in the tabs but not in the hamburger

Environment

MahApps.Metro version: all last RC
Target Core 8

TheCamel avatar Jun 13 '24 06:06 TheCamel

StringManager.zip

file attached

TheCamel avatar Jun 13 '24 06:06 TheCamel

@punker76 Hello Jan, we are wondering if the support for mahapps is discontinued or not because there are not so much updates on it ? as we would like to use it on production app, it is quite difficult for us to make a choice - or not. Do you need help and contribution ? If we spend time on it will it be taken in account ? Thanks in advance for your return.

TheCamel avatar Aug 27 '24 09:08 TheCamel

@TheCamel No no, support is not stopped. Currently not so much time, but I try to do my best. I currently invested time to solve this issue here, but I have no due date for a fix. If you want to contribute then feel free to start and create PRs. Thx Jan

punker76 avatar Aug 27 '24 16:08 punker76

@punker76 , just a short word. I found out where it comes from...but i would like to understood first :-)

TheCamel avatar Aug 28 '24 10:08 TheCamel

Hi @punker76, I've been working on this for a few days now and I think I've come to a conclusion. Without any criticism, I think that there is a design error in the component and the use of items/template/etc...

In the WPF philosophy: -Either you put direct items in the control with everything you need such as treeviewitems, etc... -or you define an ItemTemplate and/or datatemplates in conjunction with an item source collection of models (not very useful for a hamburger but who knows an application could define its menu in database via models)

but here there's a mixture of the 2... it even crashes visual sutdio if I mess with the code too much. I've also noticed that the icons aren't displayed in the designer in the current version

then you wanted to do the right thing and offer menuitems with templates and styles, but that's not the role of a graphical component; look at listboxes, etc., they only display a label by default. Hamburger should handle lists, that's all, with a style container ok but no more.

I've kept the templating on the splitView because it works perfectly. However, I turned Hamburger into a Selector (ItemControl with current item management) and added the OptionList and Content properties.

ItemsSources => click or commands=>change content. Option=>Click =>no content change, just an action.

I've removed everything else, it's much simpler. No more special listboxes, no more items and interfaces, no more selector style. A lot less xaml and code.

I put in a demo tab and deleted the old code to make sure I didn't make a mistake and to have a mix of code.

Then if you don't want to use/integrate my proposal, there's no problem, I understand, I can integrate the new burger control directly into my app, or even make a copy of mahapps because I have other ideas.

My code is in https://github.com/TheCamel/MahApps.Metro/tree/issues_4492

I'll be waiting for you to get back to me as soon as possible to decide whether or not to PR it.

TheCamel avatar Aug 30 '24 12:08 TheCamel

@punker76 Jan, no news from you? and my proposal? You can refuse :-) Regards

TheCamel avatar Oct 07 '24 16:10 TheCamel

I worked on a solution (inspired by your inspection and solution), but had no time to finish yet...

punker76 avatar Oct 07 '24 16:10 punker76

@punker76 Hi, fyi the same problem exist on the MultiSelectionComboBox ; items in the textbox and the list never get translated...

TheCamel avatar Oct 14 '24 09:10 TheCamel