Xceed DataGrid for Silverlight Documentation
FlagPathConverter Class

Imports System
Imports System.Windows.Data
Imports System.Windows.Media.Imaging
Imports System.Windows
 
Namespace Xceed.Silverlight.Documentation

  Public Class FlagPathConverter 
               Implements IValueConverter
  
    Public Function Convert( ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo ) As Object Implements IValueConverter.Convert
    
      If( value Is Nothing Or value.ToString() = String.Empty )
        Return New BitmapImage()
      End If
      
      Return New BitmapImage( New Uri( "Flags/" + value.ToString().ToLower() + ".png", UriKind.Relative ) )
    End Function
 
    Public Function ConvertBack( ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, Byval culture As System.Globalization.CultureInfo  ) As Object Implements IValueConverter.ConvertBack
    
      Return DependencyProperty.UnsetValue
    End Function
  End Sub
End Namespace
using System;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using System.Windows;
 
namespace Xceed.Silverlight.Documentation
{
  public class FlagPathConverter : IValueConverter
  {
    public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
    {
      if( value == null || value.ToString() == String.Empty )
        return new BitmapImage();
     
      return new BitmapImage( new Uri( "Flags/" + value.ToString().ToLower() + ".png", UriKind.Relative ) );
    }
 
    public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
    {
      return DependencyProperty.UnsetValue;
    }
  }
}

 

Send Feedback