title: WPF Converter is not working
body: <p>Friends I am using converter for the first time. I want to convert between Bool and String for the Visibility purpose of Button 'Help'. Getter-Setter for HelpVisibility are working but I am not sure why visibility of button is not working. Below is my code. Please help.</p>
  
  <p><strong>VehicalForm.xaml</strong></p>
  
  <pre><code>&lt;Window x:Class="Seris.VehicleForm"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              Title="MainWindow" Height="500" Width="650"
              xmlns:l="clr-namespace:Seris.Converters"&gt;
  &lt;Window.Resources&gt;
      &lt;l:Bool2String x:Key="converter" /&gt;
  &lt;/Window.Resources&gt;
  &lt;Control&gt;
  
      &lt;Control.Template&gt;
  
          &lt;ControlTemplate&gt;
  
              &lt;WrapPanel Orientation="Vertical" Margin="10 " &gt;
  
                  &lt;Label Content="Vehical No" HorizontalAlignment="Left"/&gt;
                  &lt;TextBox Name="VehicalNo_Text" Height="23" Width="80" TextWrapping="Wrap" Text="{Binding VehicalNo, UpdateSourceTrigger=PropertyChanged}"  HorizontalAlignment="Left" /&gt;
  
                  &lt;Label Content="Model" HorizontalAlignment="Left"/&gt;
                  &lt;TextBox Name="Model_Text" Height="23" Width="80" TextWrapping="Wrap" Text="{Binding Model, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" /&gt;
  
                  &lt;Label Content="Manufacturing Date" HorizontalAlignment="Left"/&gt;
                  &lt;DatePicker Name="ManufacturingDate_DateTime" SelectedDate="{Binding ManufacturingDate, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Width="136"/&gt;
  
                  &lt;Label Content="IU No" HorizontalAlignment="Left"/&gt;
                  &lt;TextBox Height="23" Width="80" Name="IUNO_Text" TextWrapping="Wrap" Text="{Binding IUNo, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left"/&gt;
  
                  &lt;Label Content="Personnel" HorizontalAlignment="Left"/&gt;
                  &lt;ComboBox Name="Personnel_Combo" SelectedValue="{Binding PersonnelNameSelected, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding PersonnelName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" HorizontalAlignment="Left" Width="126"/&gt;
  
                  &lt;Separator Height="20" RenderTransformOrigin="0.5,0.5" Width="16"/&gt;
  
                  &lt;Button Name="Save_Button" Command="{Binding SaveButton_Command}" Content="Save" Width="66"/&gt;
                  &lt;Button Name="Replace_Button" CommandParameter="replace" IsEnabled="{Binding isEnableReplaceButton, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Command="{Binding ReplaceButton_Command}" Content="Replace" Width="66"/&gt;
                  &lt;Button Name="Remove_Button" CommandParameter="replace" IsEnabled="{Binding isEnableReplaceButton, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Command="{Binding RemoveButton_Command}" Content="Remove" Width="66"/&gt;
  
  
                  &lt;Label x:Name="Error_Label" Content="{Binding ErrorMessage, UpdateSourceTrigger=PropertyChanged}" Foreground="Red" HorizontalAlignment="Left" Height="41" Width="137"/&gt;
  
                  &lt;ListView Name ="Grid" Height="294" Width="371" &gt;
                      &lt;DataGrid Name="DG" ItemsSource="{Binding ListItems, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedRow, Mode=TwoWay}" GridLinesVisibility="None" IsReadOnly="True" AutoGenerateColumns="False" BorderThickness="0"&gt;
                          &lt;DataGrid.Columns&gt;
                              &lt;DataGridTextColumn Header="Vehical No" Binding="{Binding VehicalNo}"/&gt;
                              &lt;DataGridTextColumn Header="Model" Binding="{Binding Model}" /&gt;
                              &lt;DataGridTextColumn Header="ManufacturingDate" Binding="{Binding ManufacturingDate}" /&gt;
                              &lt;DataGridTextColumn Header="IUNo" Binding="{Binding IUNo}" /&gt;
                              &lt;DataGridTextColumn Header="Personnel" Binding="{Binding PersonnelNameSelected}" /&gt;
                          &lt;/DataGrid.Columns&gt;
                      &lt;/DataGrid&gt;
                  &lt;/ListView&gt;
  
                  &lt;TextBlock Name="Notification" Text="{Binding EditText, UpdateSourceTrigger=PropertyChanged}"/&gt;
  
                  &lt;ProgressBar Name="Progressbar" Minimum="0" Maximum="100" Value="{Binding Progress, UpdateSourceTrigger=PropertyChanged}" Height="11"/&gt;
                  &lt;TextBlock Text="{Binding ElementName=Progressbar, Path=Value, StringFormat={}{0:0}%}" HorizontalAlignment="Center" VerticalAlignment="Center" /&gt;
  
                  &lt;Button Name="Help" Visibility="{Binding HelpVisibility, Converter={StaticResource converter}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" CommandParameter="help" Height="50" Width="50" Click="Help_Click" HorizontalAlignment="Right"&gt;
                      &lt;Image Height="45" Width="45" Source="../Images/help.jpg" HorizontalAlignment="Left"/&gt;
                  &lt;/Button&gt;
  
              &lt;/WrapPanel&gt;
  
          &lt;/ControlTemplate&gt;
  
      &lt;/Control.Template&gt;
  
  &lt;/Control&gt;
  
  &lt;/Window&gt;
  </code></pre>
  
  <p><strong>Bool2String.cs</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows.Data;
  
  namespace Seris.Converters
  {
  class Bool2String : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          if (value is bool)
              return bool.TrueString;
          return null;
      }
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
  
          if (value is string)
          {
              if (value == "true")
                  return true;
              else if (value == "false")
                  return false;
          }
          return null;
      }
  }
  }
  </code></pre>
  
  <p><strong>VehicalMainViewModel.cs</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Seris.Models;
  using System.Collections.ObjectModel;
  using System.Windows.Input;
  using Seris.Commands;
  using Seris.ViewModels;
  using System.Windows;
  using System.Windows.Controls;
  using System.Threading;
  using System.ComponentModel;
  using Seris.Views;
  
  namespace Seris.ViewModels
  {
  public class VehicleMainViewModel : ObservableObject
  {
  
  
      #region Getters-Setters
  
      // Static Variables
  
      private static bool _IsEnableReplaceButton;
      public static bool IsEnableReplaceButton
      {
          get { return _IsEnableReplaceButton; }
          set { _IsEnableReplaceButton = value; }
      }
  
      // Non-Static Variables
  
      public ObservableCollection&lt;VehicleModel&gt; _listItems;
  
      public ObservableCollection&lt;VehicleModel&gt; ListItems
      {
          get { return _listItems; }
          set
          {
              if (value == null || (!value.Equals(_listItems)))
              {
                  _listItems = value;
              }
          }
      }
  
  
      private int _Progress;
  
      public int Progress
      {
          get { return _Progress; }
          set { _Progress = value; OnPropertyChanged("Progress"); }
      }
  
      private string _ErroMesage;
  
      public string ErrorMessage
      {
          get { return _ErroMesage; }
          set 
          { 
              _ErroMesage = value; OnPropertyChanged("ErrorMessage");
              if (ErrorMessage.Trim() == "" || ErrorMessage == null)
                  HelpVisibility = false;
              else
                  HelpVisibility = true;
          }
      }
  
      private bool _HelpVisibility;
      public bool HelpVisibility
      {
          get { return _HelpVisibility; }
          set { _HelpVisibility = value; OnPropertyChanged("HelpVisibility"); }
      }
  
  
      private Guid? _UniqueNo;
  
      public Guid? UniqueNo 
      {
          get { return _UniqueNo; }
          set
          {
              if (value == null || (!value.Equals(_UniqueNo)))
              {
                  _UniqueNo = value;
                  OnPropertyChanged("VehicalNo");
  
              }
          }
      }
  
      private string _VehicalNo;
  
      public string VehicalNo 
      {
          get { return _VehicalNo; }
          set
          {
              if (value == null || (!value.Equals(_VehicalNo)))
              {
                  _VehicalNo = value;
                  EditText = _VehicalNo;
                  OnPropertyChanged("VehicalNo");
  
              }
          }
      }
      private string _Model;
  
      public string Model
      {
          get { return _Model; }
          set
          {
              if (value == null || (!value.Equals(_Model)))
              {
                  _Model = value;
                  EditText = _Model;
                  OnPropertyChanged("Model");
              }
          }
      }
      private DateTime? _ManufacturingDate;
  
      public DateTime? ManufacturingDate
      {
          get { return _ManufacturingDate; }
          set
          {
              if (value == null || (!value.Equals(_ManufacturingDate)))
              {
                  _ManufacturingDate = value;
                  EditText = _ManufacturingDate.ToString();
                  OnPropertyChanged("ManufacturingDate");
              }
          }
      }
      private string _IUNo;
  
      public string IUNo
      {
          get { return _IUNo; }
          set
          {
              if (value == null || (!value.Equals(_IUNo)))
              {
                  _IUNo = value;
                  EditText = _IUNo;
                  OnPropertyChanged("IUNo");
              }
          }
      }
      private ObservableCollection&lt;string&gt; _PersonnelName;
  
      public ObservableCollection&lt;string&gt; PersonnelName
      {
          get { return _PersonnelName; }
          set
          {
              if (value != _PersonnelName)
              {
                  _PersonnelName = value;
                  EditText = _VehicalNo;
                  OnPropertyChanged("PersonnelName");
              }
          }
      }
  
      private string _PersonnelNameSelected;
  
      public string PersonnelNameSelected
      {
          get { return _PersonnelNameSelected; }
          set
          {
              if (value != _PersonnelNameSelected)
              {
                  _PersonnelNameSelected = value;
                  EditText = _PersonnelNameSelected;
                  OnPropertyChanged("PersonnelNameSelected");
              }
          }
      }
  
      private string _EditText;
  
      public string EditText
      {
          get { return _EditText; }
          set
          {
              if (value != _EditText)
              {
                  _EditText = value;
                  OnPropertyChanged("EditText");
              }
          }
      }
  
      private VehicleModel _SelectedRow;
      public VehicleModel SelectedRow
      {
          get { return _SelectedRow; }
          set
          {
              if (value != _SelectedRow)
              {
                  _SelectedRow = value;
                  OnPropertyChanged("SelectedRow");
  
                  if (SelectedRow != null)
                  {
                      UniqueNo = _SelectedRow.UniqueNo;
                      VehicalNo = _SelectedRow.VehicalNo;
                      Model = _SelectedRow.Model;
                      ManufacturingDate = _SelectedRow.ManufacturingDate;
                      IUNo = _SelectedRow.IUNo;
                      PersonnelNameSelected = _SelectedRow.PersonnelNameSelected;
  
                      _IsEnableReplaceButton = true;
                  }
  
              }
          }
      } 
      #endregion
  
      #region Command Objects
      private ICommand _saveButton_Command;
  
      public ICommand SaveButton_Command
      {
          get { return _saveButton_Command; }
          set { _saveButton_Command = value; }
      }
  
      private ICommand _ReplaceButton_Command;
  
      public ICommand ReplaceButton_Command
      {
          get { return _ReplaceButton_Command; }
          set { _ReplaceButton_Command = value; }
      }
  
      private ICommand _RemoveButton_Command;
  
      public ICommand RemoveButton_Command
      {
          get { return _RemoveButton_Command; }
          set { _RemoveButton_Command = value; }
      }
      #endregion
  
      #region Methods
  
      //Static Methods
  
  
  
      #region Constructors
  
      public VehicleMainViewModel()
      {
          // Initialization
          VehicleModel vm = new VehicleModel();
          ListItems = new ObservableCollection&lt;VehicleModel&gt;();
          PersonnelName = ListOfPersonnelViewModel.PersonNameList_Updating;
          //PersonnelName = new ObservableCollection&lt;string&gt;() { "ABC", "DEF", "GHI" };
  
          // Setting Flags
          ErrorMessage = "";
          IsEnableReplaceButton = false;
          //
  
  
  
          // Commands Initialization
          SaveButton_Command = new RelayCommand(new Action&lt;object&gt;(SaveToList));
          ReplaceButton_Command = new RelayCommand(new Action&lt;object&gt;(ReplaceToList));
          RemoveButton_Command = new RelayCommand(new Action&lt;object&gt;(RemoveList));
  
      } 
  
      #endregion
  
  
  }
  }
  </code></pre>