Guest User

Untitled

a guest
Jul 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <DataTemplate x:Key="imageThumb">
  2. <Image x:Name="docImage" Width="25" Height="25" Source="/MyApp;component/images/pdf-icon.png">
  3. <Image.Effect>
  4. <DropShadowEffect ShadowDepth="1" BlurRadius="1" Opacity="0.5"/>
  5. </Image.Effect>
  6. </Image>
  7. </DataTemplate>
  8.  
  9. DataTemplate imageTemplate = (DataTemplate)this.Resources["imageThumb"];
  10.  
  11. DataGridTemplateColumn docType = new DataGridTemplateColumn();
  12. docType.Header = "Doc Type";
  13. docType.CellTemplate = imageTemplate;
  14. targetDataGrid.Columns.Add(docType);
  15.  
  16. <local:StringToObjectConverter x:Key="DocTypeToBitmap">
  17. <ResourceDictionary>
  18. <BitmapImage x:Key="pdf" UriSource="/MyApp;component/images/pdf-icon.png" />
  19. <!-- Other BitmapImages here -->
  20. <BitmapImage x:Key="__default__" UriSource="/MyApp;component/images/unknown-icon.png" />
  21. </ResourceDictionary>
  22. </local:StringToObjectConverter>
  23.  
  24. <DataTemplate x:Key="imageThumb">
  25. <Image x:Name="docImage" Width="25" Height="25" Source="{Binding docType, Converter={StaticResource DocTypeToBitmap}}">
  26. <Image.Effect>
  27. <DropShadowEffect ShadowDepth="1" BlurRadius="1" Opacity="0.5"/>
  28. </Image.Effect>
  29. </Image>
  30. </DataTemplate>
  31.  
  32. public BitmapSource ThumbnailBitmapSource {
  33. get {
  34. BitmapImage img = new BitmapImage(someUriYouGetBasedOnDocType);
  35. return img;
  36. }
  37. }
  38.  
  39. partial void OnDocTypeChanged() {
  40. this.RaiseDataMemberChanged("ThumbnailBitmapSource");
  41. }
Add Comment
Please, Sign In to add comment