Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <DataTemplate DataType="{x:Type modeldata:ImageInfo}">
- <Image
- Margin="6"
- Source="{Binding Thumbnail}"
- Width="{Binding ZoomBarWidth.Width, Source={StaticResource zoombarmanager}}"
- Height="{Binding ZoomBarWidth.Width, Source={StaticResource zoombarmanager}}"/>
- </DataTemplate>
- <Grid DataContext="{StaticResource imageinfolder}">
- <ScrollViewer
- VerticalScrollBarVisibility="Auto"
- HorizontalScrollBarVisibility="Disabled">
- <ListBox Name="PhotosListBox"
- IsSynchronizedWithCurrentItem="True"
- Style="{StaticResource PhotoListBoxStyle}"
- Margin="5"
- SelectionMode="Extended"
- ItemsSource="{Binding}"
- />
- </ScrollViewer>
- <Style~~ TargetType="{x:Type ListBox}" x:Key="PhotoListBoxStyle">
- <Setter Property="Foreground" Value="White" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ListBox}" >
- <WrapPanel
- Margin="5"
- IsItemsHost="True"
- Orientation="Horizontal"
- VerticalAlignment="Top"
- HorizontalAlignment="Stretch" />
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style~~>
- <ListBox.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel Orientation="Horizontal"/>
- </ItemsPanelTemplate>
- </ListBox.ItemsPanel>
- <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
- <ListBox.ItemsPanel>
- <ItemsPanelTemplate>
- <StackPanel>
- <StackPanel.LayoutTransform>
- <ScaleTransform
- ScaleX="{Binding Path=Value, ElementName=ZoomSlider}"
- ScaleY="{Binding Path=Value, ElementName=ZoomSlider}" />
- </StackPanel.LayoutTransform>
- </StackPanel>
- </ItemsPanelTemplate>
- </ListBox.ItemsPanel>
- class PathToThumbnailConverter : IValueConverter {
- public int DecodeWidth {
- get;
- set;
- }
- public PathToThumbnailConverter() {
- DecodeWidth = 200;
- }
- public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
- var path = value as string;
- if ( !string.IsNullOrEmpty( path ) ) {
- FileInfo info = new FileInfo( path );
- if ( info.Exists && info.Length > 0 ) {
- BitmapImage bi = new BitmapImage();
- bi.BeginInit();
- bi.DecodePixelWidth = DecodeWidth;
- bi.CacheOption = BitmapCacheOption.OnLoad;
- bi.UriSource = new Uri( info.FullName );
- bi.EndInit();
- return bi;
- }
- }
- return null;
- }
- public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
- throw new NotImplementedException();
- }
- }
Add Comment
Please, Sign In to add comment