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
1 answer

wpf datagrid observablecollection

I'm working on a large database application using WPF. So far, I have been able to create a DataContext using Link to Sql class, store it in an ObservableCollection, and feed it to my DataGrid as DataContext. The main table in SQL I'm trying to…
jxd215
  • 77
  • 4
  • 13
0
votes
1 answer

'Converter' does not implement interface member System.Windows.Data.IValueConverter.Convert

I got this error when I try to run my application: 'InsightSplash.theMenuConverter' does not implement interface member 'System.Windows.Data.IValueConverter.Convert(object, System.Type, object, System.Globalization.CultureInfo)' Any idea what's…
Huda Ahmed
  • 27
  • 6
0
votes
1 answer

is it possible the binding to two properties?

I have a view model that has two properties. One of them is myDataGridSelectedItems, that is update in the selection changed event of the datagrid (I am using MVVM light to convert an event to command). The second property is myText, that is the…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
0
votes
1 answer

WPF VB.NET Binding Image Source From String in Data Template

My first WPF application (please be gentle!), and I'm making an app based on events during a football match. So I've set up a Player class, and one of the properties is Nationality eg: Scotland. Then I have a DataTemplate, but rather than the string…
rwmck
  • 25
  • 2
  • 8
0
votes
1 answer

How can I use IValueConverter to convert a font in bold

Hi I am trying to convert the font style of a row in a DataGrid depending on the type selected by a combobox. I'm not getting and is returning the following error: "Error 18 'System.Windows.Documents.Bold' does not contain a constructor que takes…
0
votes
1 answer

An exception of type 'System.Exception' using a converter XAML

I am using a IValueConverter in XAML in my Windows Phone app. My code
PutraKg
  • 2,226
  • 3
  • 31
  • 60
0
votes
0 answers

Binding Image Source to resource file based on some other property

I have a ListView whose ItemsSource is bound to a collection. One of the columns of the ListView is an image. This image source must be set to a resource file, and the resource is determined by a property of the item. How Can the converter return…
xaria
  • 842
  • 5
  • 24
  • 47
0
votes
2 answers

Winrt IValueConverter on a GridView item

I have a ObservableCollection Laps which I am databinding to a gridview. This works as expected but I need to apply a converter to set the format of the TimeSpan: In my resources: My…
Peter
  • 1,685
  • 3
  • 16
  • 22
0
votes
2 answers

Using an IValueConverter to enable/disable button's IsDefault Property

My view has 2 buttons called BrowseButton and UploadButton. BrowseButton is default and UploadButton is not. My goal is for the default to change after BrowseButton is clicked (ie BrowseButton is not default but UploadButton is). When BrowseButton…
Dave
  • 8,163
  • 11
  • 67
  • 103
0
votes
1 answer

Two IMultiValueConverters with identical code, but different names - only one works

I'm having a weird WPF issue. I have two IMultiValueConverter definitions in an assembly that is referenced by my WPF project. Their code is identical, but their names are different. I have cleaned and rebuilt the assemblies multiple times, but…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
0
votes
1 answer

Convert 0 to an image

I have a telerik rad grid with two columns, 1. isconstraint, 2. Quantity isconstraint is a bool which dislays true or false. quantity is int My requirment is to convert 0's in the quantity column to an image or a color brush if the isconstraint is…
Karthik
  • 115
  • 1
  • 12
0
votes
0 answers

Binding a converter to missing property

I have an IEnumerable containing IPerson's. These IPerson end up as different interfaces. Some of the persons, will have a property called DirectReports but some will not have this property. Only IManager will. I bind a list of direct reports, to…
Nicolai
  • 2,835
  • 7
  • 42
  • 52
0
votes
1 answer

IValueConverter that sets FontWeight and FontStyle

How can an IValueConverter return FontWeights.Bold and FontStyles.Italic? Based on the value, my converter needs to set the textblock to Bold and Italic or just Normal.
Jerry
  • 6,357
  • 8
  • 35
  • 50
0
votes
1 answer

WPF ComboBox Popup template with border changing background color every system color changes

I have here my customized ComboBox: It's actually a browser selection. But right now what you see there is a prototype of the selector control using ComboBox. The problem I am having is this dropdown (Popup) control background The background color…
Jayson Ragasa
  • 1,011
  • 4
  • 19
  • 33
0
votes
1 answer

WPF AutoCompleteBox Multiple ValueMemberPath

I have a CollectionViewSource populated with business objects from a database. Setting the AutoCompleteBox ValueMemberPath="LNAME" works as intended for all last names. However, I would like to search first name and order number concurrently without…
BCCode
  • 94
  • 1
  • 6