Questions tagged [ivalueconverter]

IValueConverter is an interface defined in Microsoft .NET XAML for use in WPF, Silverlight and Xamarin.Forms. It is used in data binding to convert data from one format to another. The conversion can be one-way or bidirectional.

The .NET Binding classes have an optional Converter property of type IValueConverter which can be used to convert data from its native internal representation to something more convenient to a specific UI objective. A DateTime object could be converted to a string representation in a particular date/time display format, for example, or a numeric value could be converted to a color value for the background of a status control.

IValueConverter defines two methods: Convert and ConvertBack. Implement Convert to convert the source data to the display data representation. Implement ConvertBack to convert the display data representation to the source data representation. This is useful when the UI allows the user to edit the data. In the DateTime example above, if the display data were bound to a TextBox edit control (and the data binding Mode is set to TwoWay), the user could type in or change the date/time values. The IValueConverter specified on the data binding would be responsible for converting the text the user entered into a DateTime value in its ConvertBack method.

For more information, see the MSDN documentation on the IValueConverter interface.

668 questions
0
votes
2 answers

XAML Converter doesn't work

I have a ScreenHeightConverter, and want to use it on the ItemHeight of a GridView. But I don't know if I use it properly, because if I debug it, it doesn't even jump to the converter. My Code: public class ScreenHeightConverter :…
user1572130
  • 65
  • 10
0
votes
3 answers

how to make checkbox check and uncheck wpf

I have taken checkbox in datagrid and binding the datagrid …
Rocky
  • 4,454
  • 14
  • 64
  • 119
0
votes
2 answers

converter not showing the color

hey guys i have this converter : public class BudgetIndicatorConverter :IValueConverter { public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture) { string Indicator =…
Arrie
  • 1,327
  • 5
  • 18
  • 39
0
votes
0 answers

WPF error happened when bind eumn to ComboBox

I have a enum like following: public enum ProcessControlSysType { PFS = 1, MES = 2, } I bind it to a combobox as itemsource like following:
LIU
  • 295
  • 1
  • 4
  • 11
0
votes
1 answer

Getting specific object out of public class in silverlight

Hey guys i have this converter class : public class InboxItemValueConverters : IValueConverter { public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture) { int…
Arrie
  • 1,327
  • 5
  • 18
  • 39
0
votes
1 answer

How do I use ConverterParameter in C++/Cx?

I started a new Visual C++ project in Visual Studio and as part of the template, I got a BooleanToVisibilityConverter. This works fine, but it doesn't seem to honor ConverterParameter=Invert when specified. XAML:
Brent Traut
  • 5,614
  • 6
  • 29
  • 54
0
votes
3 answers

Unable to get DisplayMemberPath to show bound object data in listbox

To cut a long story short I have a section of my application that contains a series of listboxes bound to an object instance in Xaml. Using an IValueConverter, I was able to retrieve a list of objects from the master object and display the…
ChargerIIC
  • 1,620
  • 1
  • 33
  • 47
0
votes
1 answer

not able to get file size in string with bytes to string converter in c#/XAML metro app

I just want to convert file size in string format like "1 MB" or "2.5 GB", I referred converter from Q.42 library I think, I may be having mistake in my XAML code, please help me to figure out this. MainPage.XAML
Farhan Ghumra
  • 15,180
  • 6
  • 50
  • 115
0
votes
2 answers

IValueConverter for collection

I have ComboBoxes than bind to collections of type int or double in my Silverlight application. These collections hold the possible valid values that can be selected by the user. I need to also have an "Auto" option in the ComboBox. In my code, I am…
Ethan
  • 628
  • 2
  • 6
  • 20
0
votes
1 answer

Convert a double rating into images with IValueConverter

I get a rating of meals from a webservice as a double value. In my Xaml I want to convert this value into star images. The range is from 0 - 5 and I want be able to convert every 0.5 steps. If I get a rating of 3.75, I want to have three "full…
Manuel Rauber
  • 1,583
  • 1
  • 17
  • 39
0
votes
0 answers

Data Binding Converter "does not implement interface member"

I am having problems using a binding converter written in code-behind, with the corresponding markup. It keeps giving me the same error: does not implement interface member 'System.Windows.Data.IValueConverter.Convert(object, System.Type, object,…
0
votes
1 answer

Visibility of two controls via data binding and value converter

I have two controls contained within a data template. Control #1 is a TextBlock known as "TXTBLOCK". Control #2 is a TextBox known as "TXTBOX": TXTBLOCK has Visibility set to TextBox Visibility using the converter to give the opposite…
tronious
  • 1,547
  • 2
  • 28
  • 45
0
votes
2 answers

How to bind content in WP7 button

I have earlier asked how to convert static values of TextBlocks using bindings and IValueConverter as seen here. Now I would like to do the exact same thing, but with buttons instead. But the problem is, that buttons do not have the DataContext…
Zappel
  • 1,612
  • 1
  • 22
  • 37
0
votes
1 answer

How do I refresh a bound property because of an "unrelated" change when a user navigates back?

I have the following two models in my app: public class AppSettings : INotifyPropertyChanged { private Units _mainUnits; // Units is an Enum. public Units MainUnits { get { return _mainUnits; } set { if (!_mainUnits != value)…
Zhaph - Ben Duguid
  • 26,785
  • 5
  • 80
  • 117
0
votes
0 answers

Binding with ValueConverter to object in another window

I have a main program window with a row of shortcut buttons along the bottom. I'm trying to make the Visibility of these selectable through a separate Settings window using CheckBoxes, and then store that state in the UserSettings of the program so…
Keven M
  • 972
  • 17
  • 47