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

Binding on RibbonWindow.Icon not working #511

Closed
PatrickHofman opened this issue Jan 31, 2018 · 1 comment
Closed

Binding on RibbonWindow.Icon not working #511

PatrickHofman opened this issue Jan 31, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@PatrickHofman
Copy link

PatrickHofman commented Jan 31, 2018

I have implemented a Ribbon inside a RibbonWindow. I am using a view model to dynamically change the window icon based on some input. It seems that binding the Icon property doesn't work. The icon which is set on the binding source (the view model) isn't taken over by the RibbonWindow. It remains empty.

Probably this is an issue with an early evaluation of the value and internal setting the then-selected ImageSource on the PART_Icon part.


Environment

  • Fluent.Ribbon 6.0.0.208
  • Windows 10 version 1709 build 16299.192
  • .NET Framework 4.7.1

Code

XAML:

Icon="{Binding ApplicationIcon}"

this.DataContext is set through the window constructor to a model defining ApplicationIcon. Having the exact same binding on a regular Window does work.


Workaround

I currently have a workaround where I manually set a binding on the PART_Icon through the OnApplyTemplate (in a derived class, so it keeps the current default working of RibbonWindow.OnApplyTemplate):

public override void OnApplyTemplate()
{
    base.OnApplyTemplate();

    const string PART_Icon = "PART_Icon";

    Image iconImage = this.GetTemplateChild(PART_Icon) as Image;

    if (iconImage != null)
    {
        Binding myBinding = new Binding();
        myBinding.Source = this;
        myBinding.Path = new PropertyPath(nameof(Icon));
        myBinding.Mode = BindingMode.TwoWay;
        myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
        BindingOperations.SetBinding(iconImage, Image.SourceProperty, myBinding);
    }
}
@batzen batzen self-assigned this Jan 31, 2018
@batzen
Copy link
Member

batzen commented Jan 31, 2018

There is a bug in the IconConverter.
If your image is not derived from BitmapFrame it returns null where it should return the input value.

@batzen batzen added this to the 6.0.1 milestone Feb 3, 2018
@batzen batzen closed this as completed in 8838c37 Feb 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants