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,
I done the following changes in the provided sample , to view the gallery items in the preview area of the gallerytool. Otherwise no items were visible in the preview area.
<TextBlock x:Name="text" Grid.Row="1" Grid.Column="0"
Foreground="{DynamicResource {x:Static igRibbon:RibbonBrushKeys.ToolEnabledForegroundTextFillKey}}"
TextAlignment="{TemplateBinding HorizontalTextAlignmentResolved}"
VerticalAlignment="{TemplateBinding VerticalTextAlignmentResolved}"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Item.Text}" TextWrapping="Wrap" MaxWidth="120"/>
The problem is still that , for the preview items,if the text of the gallery item is very long, only the middle portion of the text is visible in the gallery preview.
Your style redefined the TextBlock within the GalleryItemPresenter and I think that is the issue you are running into. I'm going to add your style and ribbon to my sample so you can see the impact.
I replaced some of the properties in your style and that resolved your issues.
Let me know if you have any questions.
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"
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)
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.