Skip to content

Commit

Permalink
Fixes #1091
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Mar 21, 2023
1 parent 9ed8cd3 commit 41c01ab
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- [#1048](../../issues/1048) - DismissOnClickOutside property added to DropDownButton (thanks @MuhammadSulaiman001)
- [#1049](../../issues/1049) - IsDisplayOptionsButtonVisible property is added to RibbonTabControl (thanks @zui-jiu-zhou)
- [#1058](../../issues/1058) - Add option to use legacy/office-style mouse wheel tab shifting (thanks @andersforsgren)
- [#1091](../../issues/1091) - Image Resource Viewer (thanks @avalanchus)
- [#1112](../../issues/1112) - Enhanced FocusVisual for various controls (thanks @cbra-caa)

## 9.0.4
Expand Down
75 changes: 75 additions & 0 deletions Fluent.Ribbon.Showcase/ImagesViewer.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<UserControl x:Class="FluentTest.ImagesViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluentTest="clr-namespace:FluentTest"
xmlns:fluent="urn:fluent-ribbon"
mc:Ignorable="d"
d:DesignHeight="1280"
d:DesignWidth="800"
d:DataContext="{d:DesignInstance fluentTest:ImagesViewerDesignTimeData, IsDesignTimeCreatable=True}">
<UserControl.DataContext>
<fluentTest:ImagesViewerDesignTimeData />
</UserControl.DataContext>
<Grid>
<ItemsControl ItemsSource="{Binding Data}"
Background="Transparent"
Grid.IsSharedSizeScope="True">
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer Padding="{TemplateBinding Padding}">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="4 0 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="S16" />
<ColumnDefinition Width="Auto" SharedSizeGroup="S32" />
<ColumnDefinition Width="Auto" SharedSizeGroup="S48" />
<ColumnDefinition Width="Auto" SharedSizeGroup="S64" />
<ColumnDefinition Width="Auto" SharedSizeGroup="Label" />
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="4"
Margin="4 0 0 0"
VerticalAlignment="Center"
Text="{Binding Key}" />

<Image Grid.Column="0"
Source="{Binding Value}"
Margin="2"
Width="16"
Height="16" />

<Image Grid.Column="1"
Source="{Binding Value}"
Margin="2"
Width="32"
Height="32" />

<Image Grid.Column="2"
Source="{Binding Value}"
Margin="2"
Width="48"
Height="48" />

<Image Grid.Column="3"
Source="{Binding Value}"
Margin="2"
Width="64"
Height="64" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>
33 changes: 33 additions & 0 deletions Fluent.Ribbon.Showcase/ImagesViewer.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace FluentTest;

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Media;

public partial class ImagesViewer
{
public ImagesViewer()
{
this.InitializeComponent();
}
}

public class ImagesViewerDesignTimeData
{
public ImagesViewerDesignTimeData()
{
var dictionary = new ResourceDictionary { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Images.xaml", UriKind.Absolute) };

foreach (var key in dictionary.Keys.Cast<string>().OrderBy(x => x))
{
#pragma warning disable CA1307
this.Data.Add(new KeyValuePair<string, DrawingImage>(key.Replace("Fluent.Ribbon.Images.", string.Empty), (DrawingImage)dictionary[key]));
#pragma warning restore CA1307
}
}

public ObservableCollection<KeyValuePair<string, DrawingImage>> Data { get; } = new();
}
5 changes: 5 additions & 0 deletions Fluent.Ribbon.Showcase/TestContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:FluentTest.ViewModels"
xmlns:fluentTest="clr-namespace:FluentTest"
x:Name="TestContentControl"
d:DataContext="{d:DesignInstance viewModels:MainViewModel,
IsDesignTimeCreatable=True}"
Expand Down Expand Up @@ -3671,6 +3672,10 @@
</formsInterop:WindowsFormsHost>
</DockPanel>
</TabItem>

<TabItem Header="Images">
<fluentTest:ImagesViewer />
</TabItem>
</TabControl>

<Fluent:StatusBar Grid.Row="2"
Expand Down

0 comments on commit 41c01ab

Please sign in to comment.