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

Converting an integer to a string, through an object

I'm pretty new to XAML and WPF, and I'm trying to build a Converter, which converts an integer to a month (string) I know the code below doesn't work because it gets an object rather than a string to process, but I have no idea how to handle this…
user3208179
  • 367
  • 1
  • 6
  • 12
0
votes
0 answers

Refreshing a binding that uses a value converter within a style

I am using a Telerik RadTimeline control in my project, I have a template for the TimelineItemTemplate:
Juan Alberto
  • 165
  • 3
  • 18
0
votes
1 answer

IValueConverter and non constant value

using c#, WPF I try to create IValueConverter for converting ID from dataBase to another value from another table in same dataBase. Example: I have one person with ID "1" and in another table NAME "James" for this ID. What I want - to bind ID to…
hbk
  • 10,908
  • 11
  • 91
  • 124
0
votes
1 answer

Referring to an element of the 'value' set passed to a converter

I'm sorry to ask a really basic question but am working on having a converter in code behind xaml page. This converter would change a background color based on the value in a data element. I know the data element I want is available because when I…
wheezer
  • 135
  • 1
  • 2
  • 9
0
votes
2 answers

How to convert TextView to int?

I know that there are a lot of posts like this but I read them and my application does not work yet. Im trying to convert TextView parameter into int. I use this: int MyScore; TextView score = (TextView) findViewById(R.id.highscore); MyScore =…
Omri Attiya
  • 3,917
  • 3
  • 19
  • 35
0
votes
0 answers

Issues Implementing Mutually Exclusive Radio Buttons in WPF

I have read numerous tutorials and spent hours trying to figure out how to bind a group of radio buttons to an enum the correct way. I have followed numerous tutorials and tried different methods with no luck. My exact issue is: Whenever I select a…
Rich E
  • 233
  • 2
  • 10
0
votes
2 answers

how to notify change in the first element of the hashset?

I have a propery that is a hashset, and I would like to notify to the view when a property of the first element is changed. I implemented the iterface for notify when the property changed, but I don't know how to notifiy to the view. I have this…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
0
votes
1 answer

How to create user defined converter() equivalent function replacing converter(defined in IValueConverter)

I am c# silvelight5 beginner and under a situation that i have to create my own Converter() function which must be similar like Converter() function derived from IValueConverter Interface. What data i have right now ? I have correctly deserialized…
Sss
  • 1,519
  • 8
  • 37
  • 67
0
votes
2 answers

Convert string to int using IValueConverter

How do I convert string values to integers and back using IValueConverter? I have a database that consists of two tables; table CompanyX and table DeptY. Table CompanyX has field ID(int), firstName, lastName, Email, Phone. Table DeptY has field…
AndyRoxxx
  • 19
  • 1
  • 1
  • 5
0
votes
1 answer

How to create XAML container for combo box which is created?

I am working on c# silverlight5 and i am using mvvm approach to do so. I have a situation where i have to create container in xaml which could accomodate the GUI which contains combo box and labels and text boxes which are created using c# code. I…
Sss
  • 1,519
  • 8
  • 37
  • 67
0
votes
2 answers

Dependency propery for ValueConverter or rebind control?

I have custom control with some text in content template:
alek.sys
  • 23
  • 1
  • 2
0
votes
1 answer

Freezing a bitmap image in a IValueConverter

I have an application that uses a bitmap converter. The converter will process hundreds/thousands of images during the app's execution. Slight twist: In the event that the converter throws an exception (for one reason or another), I need the…
Gayot Fow
  • 8,710
  • 1
  • 35
  • 48
0
votes
2 answers

Using ValueConverter in Style DataTrigger of ItemsControl but List is Empty

I am attempting to use a ValueConverter to flip the last item in an ItemsControl (so that it appears backwards). To accomplish this, I created a Style with a DataTrigger which is using a ValueConverter to check if the current item is the last item…
Goose
  • 1,307
  • 2
  • 14
  • 28
0
votes
0 answers

Apply Converter on Textblock inside Content Presenter

I have a custom ControlTemplate for my Groupbox: