Hi,
I'm currently working on a Ribbon gallery that should behave similar to the "Page Sizes" menu in Word 2010 (see attached screenshot - it's in german). It's not resize-able and all gallery items are left-aligned.
Everything works fine except the alignment of the gallery items. They are always centered, even though I added following styling to the GalleryItems:
<igRibbon:GalleryTool.ItemSettings> <igRibbon:GalleryItemSettings TextPlacement="RightOfImage" HorizontalTextAlignment="Left" /></igRibbon:GalleryTool.ItemSettings>
The example I used for the gallery is taken from here:http://help.infragistics.com/Help/NetAdvantage/WPF/2011.2/CLR4.0/html/xamRibbon_Gallery.html
Any ideas?
BRStephan
Hello Stephan,
I have been looking into your issue and I can suggest you some custom approaches that you can use to align the tolls in left.
The first approach that I can point you to is to copy the default template for the RibbonGroup and set the HorizontalAlignment property of the ItemsPresenter named “PART_Items” in it to Left.
Another approach that you may try is to handle the Loaded event of the XamRibbon and manually get the mentioned control from the visual tree of the specified group. For example if you have group named gr1 you can set the alignment of the tools in it as follows:
private void XamRibbon_Loaded(object sender, RoutedEventArgs e)
{
ItemsPresenter ip = Utilities.GetDescendantFromName(gr1, "PART_Items") as ItemsPresenter;
ip.HorizontalAlignment = HorizontalAlignment.Left;
}
If you need any further assistance on this matter please do not hesitate to ask.
Hello Elena,
Thanks for your quick response!
The first approach could of course solve the problem, but I would like to avoid duplicating templates just for an alignment issue. I will try to implement the second approach.
Concerning following XAML I have one more question:
<igRibbon:GalleryTool.ItemSettings><igRibbon:GalleryItemSettings TextPlacement="RightOfImage" HorizontalTextAlignment="Left" /></igRibbon:GalleryTool.ItemSettings>
What is the "HorizontalTextAligment" for? Shouldn't it align the text? Setting it does not have any impact on the alignment (Left/Right/Center/Justify).
I have been investigating further your scenario and the HorizontalTextAlignment property should refer to the text alignment position relative to the image position and depending on current TextPlacement value. In order you want to move the whole content of the GalleryItem to the left you can just set the following style for GalleryItemPresenter:
<Style TargetType="{x:Type igRibbon:GalleryItemPresenter}" x:Key="alignmentStyle">
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
<igRibbon:GalleryTool.ItemSettings>
<igRibbon:GalleryItemSettings TextPlacement="RightOfImage" GalleryItemPresenterStyle="{StaticResource alignmentStyle}" HorizontalTextAlignment="Left" />
</igRibbon:GalleryTool.ItemSettings>
If you have any additional questions on this matter please do not hesitate to ask.
I am just checking have you been able to resolve your issue? If you still need any assistance on the matter do not hesitate to ask.
Hi Elena,
thanks for your help! Using the style worked fine!