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

Issue when using templated ribbon items. #533

Closed
pschimmel opened this issue Feb 19, 2018 · 4 comments
Closed

Issue when using templated ribbon items. #533

pschimmel opened this issue Feb 19, 2018 · 4 comments
Assignees
Milestone

Comments

@pschimmel
Copy link
Contributor

I have a problem when using DataTemplates for Ribbon Controls. I basically want to define the buttons in a ViewModel and add those programmatically to the ItemsSource of the RibbonGroupBox.

<Fluent:RibbonWindow.Resources> <ResourceDictionary> <DataTemplate DataType="{x:Type local:ButtonViewModel}"> <Fluent:Button SizeDefinition="{Binding SizeDefinition}" Header="{Binding Header}"/> </DataTemplate> </ResourceDictionary> </Fluent:RibbonWindow.Resources>
The simplified VM looks like this:

` public class ButtonViewModel
{
static int id = 0;

public ButtonViewModel()
{
  ID = "Button_" + id++;
}

public string ID { get; }

public RibbonControlSizeDefinition SizeDefinition
{
  get { return new RibbonControlSizeDefinition(RibbonControlSize.Large, RibbonControlSize.Middle, RibbonControlSize.Small); }
}

public string Header => ID;

}
`

Generally it works, but the SizeDefinition is not considered. When I reduce the size of my window, the status of each group always changes directly from Large to Collapsed.

Attached is a sample project.

WpfFluentTest.zip


Environment

  • Fluent.Ribbon 6.1.0.233
  • Windows 10
  • .NET Framework 4.5
@pschimmel
Copy link
Contributor Author

I assume the problem lies in the SetSize method in RibbonProperties. When the size of a group is changed the element is a ContentPresenter.

The code
public static void SetSize(DependencyObject element, RibbonControlSize value) { element.SetValue(SizeProperty, value); }
Tries to set the Size property of the ContentPresenter, but on the ContentPresenter itself there is no such property.

Probably my DataTemplate approach is wrong.

@batzen
Copy link
Member

batzen commented Feb 19, 2018

Will try to have a look at this sometime during this week. MVVM support is not as good as it probably could be.

@batzen batzen self-assigned this Mar 3, 2018
@batzen batzen added this to the 7.0.0 milestone Mar 4, 2018
@batzen batzen closed this as completed in 05f9f9c Mar 8, 2018
@pschimmel
Copy link
Contributor Author

Hi!
Thank you for adding the fix to the 7.0.0 milestone.
Unfortunately I discovered some more problems concerning the use of data templates.

When I use the same example and add a KeyTip property to the ViewModel and use data binding in the data template as before, I get an exception in RibbonGroupBoxWrapPanel.

KeyTip="{Binding KeyTip}

When I change the data template, that it uses an attached property

Fluent:KeyTip.Keys="{Binding KeyTip}"

There is no exception, but also no KeyTips shown.

I could track down that problem to the GetVisibleChildren implementation in the KeyTipAdorner. Using a VisualTreeHelper instead of the LogicalTreeHelper to find the children might work, but is probably too expensive.

@pschimmel
Copy link
Contributor Author

Updated test project here:

WpfFluentTest.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants