Hi I am using a GalleryTool to which I have added some items. The problem is that when I give a very long name of some gallery item than when the items are visible in Gallery preview area the name of the items are centered and not fully shown. Please see the attached sample.
Hi,
The solution for you will be to re-template a copy of the GalleryItemPresenter style from the WPF Ribbon DefaultStyles. I believe you will need to modify the Grid’ that contains the TextBlock and set its HorizontalAlignment to left. You might also want to add a TextWrapping property to the TextBlock and set it to Wrap.
Please let me know if this is helpful.
Hi Marianne,
Thanks for the reply. I have implemented it as follows, Please have a look at the xaml .
<Window x:Class="GalleryToolSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igRibbon="http://infragistics.com/Ribbon"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary x:Name="resourcerDic">
<Style x:Key="galleryPresentStyle" BasedOn="{x:Null}" TargetType="{x:Type igRibbon:GalleryItemPresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igRibbon:GalleryItemPresenter}">
<Grid Margin="2,2,2,2" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="text" Grid.Row="0" Grid.Column="0"
Foreground="{DynamicResource {x:Static igRibbon:RibbonBrushKeys.ToolEnabledForegroundTextFillKey}}"
TextAlignment="Left"
Margin="5,0,5,0"
MaxWidth="115"
TextWrapping="Wrap"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Text="{Binding Path=Text}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid>
<igRibbon:XamRibbon HorizontalAlignment="Stretch" Name="xamRibbon1" VerticalAlignment="Stretch" Grid.Row="0" >
<igRibbon:RibbonTabItem Header="GALLERYTOOLITEMS" x:Name="RibbonTabItem" Width="300">
<igRibbon:RibbonGroup Id="groupId" Caption="Group">
<igRibbon:MenuTool ShouldDisplayGalleryPreview="True" Caption="GalleryToolMenu" MinWidth="200" MaxWidth="800">
<igRibbon:GalleryTool Name="galleryToolItems" AllowResizeDropDown="True" MaxPreviewColumns="3">
<igRibbon:GalleryTool.ItemSettings>
<igRibbon:GalleryItemSettings GalleryItemPresenterStyle="{StaticResource galleryPresentStyle}" HorizontalTextAlignment="Left" />
</igRibbon:GalleryTool.ItemSettings>
<igRibbon:GalleryTool.Items>
<igRibbon:GalleryItem Key="Item1" Text="Item1" />
<igRibbon:GalleryItem Key="Item2" Text="Item2 A very long name created for seeing the name in the preview area of gallery control" />
<igRibbon:GalleryItem Key="Item3" Text="Item3 "/>
<igRibbon:GalleryItem Key="Item4" Text="Item4" />
<igRibbon:GalleryItem Key="Item5" Text="Item5" />
<igRibbon:GalleryItem Key="Item6" Text="Item6" />
</igRibbon:GalleryTool.Items>
</igRibbon:GalleryTool>
</igRibbon:MenuTool>
</igRibbon:RibbonGroup>
</igRibbon:RibbonTabItem>
</igRibbon:XamRibbon>
</Window>
The gallery items in preview area looks like this(Gallery Item Text partially visible)
You may have noticed in the last sample that I sent you a copy of the GalleryItemPresenter style that I copied from our default styles. By eliminating the TextBlock's Visibility binding from that style and adding the TextWrapping and MaxWIdth properties from your style, I am able to show your preview item text as you would expect, not centered vertically but showing the item text from the beginning.
You eliminated a lot of the styling in your customization and it appears that is the cause of the behavior you are seeing.
I just commented out the references to your style so you can assign then to either Ribbon and see the impact.
Let me know if you have any other questions.
Thanks for the reply.In the provided sample without using the customizations I have made and using the default GalleryItemPresenter style with modifications, If we make the text of the Item a bit longer than the item text is still centered vertically and not showing from the beginning.
I'm not clear whether you compared the style that you provided originally to the modifications to that style that I supplied in the last sample. If you use either my modification of your style or the base style for the GalleryItemPresenter, I don't see the behavior you describe. The text is wrapping, where necessary, but the wrapped text is visible from the top.
Perhaps you have made some other modification. Please modify my sample and return it with your modifications if it does not satisfy your needs.
I was wondering if the sample was helpful. Please let me know if you have any further questions.
If I run the provided sample (without making any modification) the text for third gallery Item in the gallery preview is displayed as 'Unmistakably Large YYYYY....' whereas its text is 'BlackAndWhite Unmistakably LargeYYYYY....'.