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

Binding to a dictionary

I think I have a rather interesting problem. I have a model where the main data structure really needs to be a dictionary. I want to bind the values of that dictionary to a listbox. I have an ObservableDictionary class that fires collection…
markv12
  • 334
  • 1
  • 11
0
votes
1 answer

Is it possible to return more than one value from an ivalueconverter in wpf?

I have a wpf listbox that implements a DataTemplate that contains a TextBlock.
mherr
  • 348
  • 1
  • 7
  • 25
0
votes
1 answer

How can I use a IValueConverter in a binding for a Style without the Path to let each control assign is path at design time?

I'm trying to create a style that will attach a Converter to it so that when I use this style it will automatically use the converter. The problem I'm having is that if I don't set a path in the style, the compiler does not like it. I don't want to…
Patrick Miron
  • 221
  • 3
  • 12
0
votes
1 answer

Creating a dynamic calculated field in WPF

I am trying to create a series of dynamic, calculated fields on my window. Right now I have it working when the form loads as follows...
0
votes
3 answers

Cleaner way to bind to a DependencyProperty of the parent UserControl from a child control

I have a custom UserControl with a custom DependencyProperty. To paint a better picture of how I'm using this, the UserControl is the left navigation indicator in a wizard-like control. The left nav control exists inside of each of the controls…
Rich
  • 36,270
  • 31
  • 115
  • 154
0
votes
2 answers

Problems with IValueConverter and asynch DomainService Invoke in C#

In my searching the common solution to this problem is to add an event handler to handle once the invoke operation has completed. Unfortunately, my IValueConverter needs to return a value so having the handler is not much help. I have also tried a…
xhedgepigx
  • 340
  • 1
  • 2
  • 19
0
votes
1 answer

How do I Bind 2 controls to 1 field AND also access the 2 control values for ConvertBack?

In a DataGridTemplateColumn DataTemplate, I want to bind 2 controls to a string field of format "[name]:[value]" i.e. the string is delimited by colon ":". I need to bind control a) to the [name] part and control b) the value part. I have been able…
0
votes
1 answer

WPF: IValueConverter with List

Can use IValueConverter with List. It can use in the first time I call the menu. When I updated the items in list, it don't call IValueConverter again? Example:
0
votes
2 answers

WPF When clicking on the different Treeviewitem the related part of the text in TextBlock gets highlighted

I have a Treeview and a Textblock and both of them populated with the data from the backend by using MVVM. The TextBlock contains the formatted hex string (it looks like this: 0000: ad be e6 00 25 00 00 00 9e 7b 3b 04 40 01 db …
L Z
  • 1
  • 1
0
votes
1 answer

Pass static resource to custom System.Windows.Data.IValueConverter?

Consider the value converter below. I can easily pass values such as "Red" and "Green" to my converter, but how could I pass a brush defined in XAML? How do I bind FalseBrush to MyNiceBrush?
l33t
  • 18,692
  • 16
  • 103
  • 180
0
votes
1 answer

Creating a Converter to take an ID and create an Image in Silverlight

I am using a WCF weather service and receiving weather information like ID, Description, and Images. It returns like this: 1 Thunder Storms
Fogolicious
  • 412
  • 8
  • 22
0
votes
1 answer

Complicated Binding converting INT to Multiple WPF Visibility

Ok lets see if I'm doing this right, or am I doing it the hard way. First. I have a account level that's a integer (0-255) each Byte is set to enable given functions. I'm working on setting up the Visibility to a Given Byte Psudo XML Code
PGP_Protector
  • 218
  • 3
  • 12
0
votes
1 answer

Convert a Datagrid Cell to a hyperlink dynamically

Id like to convert the contents of a cell to a hyperlink if the string value starts with "http". It has to work dynamically and alot of the example if found hard code the column value. Ideally i would like to just use value converter to replace the…
NotARobot
  • 978
  • 2
  • 14
  • 36
-1
votes
1 answer
-1
votes
1 answer

Return DynamicResource in IValueConverter

I'm using my custom converter in my control's background. My converter will return a brush…
Hhry
  • 823
  • 1
  • 8
  • 19