fluentribbon / Fluent.Ribbon

WPF Ribbon control like in Office
http://fluentribbon.github.io
MIT License
2.53k stars 515 forks source link

Fluent.Button Header Binding not visible #961

Closed PJonHar closed 3 years ago

PJonHar commented 3 years ago

I have added a binding to the header property of a fluent.button, however when the application is running the value is not seen? I have used snoop and i can see that the binding is happy and with the correct value but it does not show?

the value 100 should be showing in the button header.

any ideas?

image

`<Fluent:Button Command="{Binding ProgramSpeedCommand}" Header="{Binding ApplicationRobotControl.Robot.ProgramSpeed, FallbackValue=0}" Icon="pack://application:,,,/KUKA.RGI v3;component/Icons/hand.ico" LargeIcon="pack://application:,,,/KUKA.RGI v3;component/Icons/hand.ico">

`
batzen commented 3 years ago

Could you remove the FallbackValue and try it again? I have seen very strange behavior of bindings in combination with fallback values recently.

PJonHar commented 3 years ago

I have tried removing the FallbackValue but the value doesnt show on the ribbon button.

batzen commented 3 years ago

Could you share a repro?

PJonHar commented 3 years ago

Sure, see attached. image

FluentRepro.zip

batzen commented 3 years ago

That's quite strange. Most controls in Fluent.Ribbon use a TemplateBinding for the header, which does not seem to work when the bound value is not a string. It works again if using a Binding with a relative source...

PJonHar commented 3 years ago

If possible could you show me a workaround please?

batzen commented 3 years ago

A workaround for you would be:

        public string ProgramSpeedString { get => programSpeed.ToString(); }
        public int ProgramSpeed { get => programSpeed; set { programSpeed = value; NotifyPropertyChanged(nameof(ProgramSpeed)); NotifyPropertyChanged(nameof(ProgramSpeedString)); } }

And then bind to ProgramSpeedString instead of ProgramSpeed.

PJonHar commented 3 years ago

Thanks. I ended up using a converter to return the ToString() of an object.