92

Ok, it was a nice surprise (after writing it several times) to find that there already is a BooleanToVisibilityConverter in System.Windows.Controls namespace.

Probably there are more such hidden time-savers.

Anyone got some?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
cz_dl
  • 1,350
  • 1
  • 9
  • 11

2 Answers2

106

I did a quick trawl using the Object Browser and this is what I have.

Derived from IValueConverter:

System.Windows.Controls.AlternationConverter
System.Windows.Controls.BooleanToVisibilityConverter
System.Windows.Documents.ZoomPercentageConverter
System.Windows.Navigation.JournalEntryListConverter

Xceed.Wpf.DataGrid.Converters.CurrencyConverter
Xceed.Wpf.DataGrid.Converters.DateTimeToStringConverter
Xceed.Wpf.DataGrid.Converters.GreaterThanZeroConverter
Xceed.Wpf.DataGrid.Converters.IndexToOddConverter
Xceed.Wpf.DataGrid.Converters.IntAdditionConverter
Xceed.Wpf.DataGrid.Converters.InverseBooleanConverter
Xceed.Wpf.DataGrid.Converters.LevelToOpacityConverter
Xceed.Wpf.DataGrid.Converters.MultimodalResultConverter
Xceed.Wpf.DataGrid.Converters.NegativeDoubleConverter
Xceed.Wpf.DataGrid.Converters.NullToBooleanConverter
Xceed.Wpf.DataGrid.Converters.SourceDataConverter
Xceed.Wpf.DataGrid.Converters.StringFormatConverter
Xceed.Wpf.DataGrid.Converters.ThicknessConverter
Xceed.Wpf.DataGrid.Converters.TypeToBooleanConverter
Xceed.Wpf.DataGrid.Converters.TypeToVisibilityConverter
Xceed.Wpf.DataGrid.Converters.ValueToMaskedTextConverter

Derived from IMultiValueConverter:

System.Windows.Controls.BorderGapMaskConverter
System.Windows.Navigation.JournalEntryUnifiedViewConverter
System.Windows.Controls.MenuScrollingVisibilityConverter

Microsoft.Windows.Themes.ProgressBarBrushConverter
Microsoft.Windows.Themes.ProgressBarHighlightConverter

Note the Xceed ones (no connection) are available free with their DataGrid. As well as those there's some clever stuff around like the debugging converter. I've also used the last IValueConverter and I'm sure there's some further lambda function goodness to be found, too.

Palec
  • 12,743
  • 8
  • 69
  • 138
MrTelly
  • 14,657
  • 1
  • 48
  • 81
  • 4
    Hope you don't mind - just edited this by sorting the findings. Nice to see what's inbuilt and what's Xceed specific. – Eddie Parker Sep 02 '14 at 23:45
  • 1
    I wonder which of them are still available in the Universal Windows Platform, for developing Windows 10 Universal Apps? – TechAurelian Nov 11 '15 at 17:52
  • 1
    On MSDN, the Version Information section contains just ".NET Framework -- Available since 3.0" for all the converters from Microsoft. Looks like Universal Windows Platform is not supported, @AHelloWorldDev. (E.g. System.Array states UWP support explicitly in Version Information section.) – Palec Nov 06 '16 at 22:13
29

Before 3.5 SP1, an IValueConverter was required for string formatting. Now, you can use the StringFormat property on Binding to do this.

From the MSDN page:

<DataTemplate>
  <TextBlock>
    <TextBlock.Text>
      <MultiBinding  StringFormat="{}{0} -- Now only {1:C}!">
        <Binding Path="Description"/>
        <Binding Path="Price"/>
      </MultiBinding>
    </TextBlock.Text>
  </TextBlock>
</DataTemplate>
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Robert Macnee
  • 11,650
  • 4
  • 40
  • 35
  • See this line for more examples: http://blogs.msdn.com/llobo/archive/2008/05/19/wpf-3-5-sp1-feature-stringformat.aspx – Ashley Davis Oct 06 '09 at 09:08
  • Also see this https://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter(v=vs.110).aspx – Tom A Jun 03 '16 at 01:41