You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
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;
}
`
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
The text was updated successfully, but these errors were encountered: