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
-1
votes
2 answers

WPF Radiobutton Group - binding to a boolean

I have a radiobutton group which I binding to a boolean value but it isn't being picked up in the XAML - am sure it's something simple I am missing - any pointers appreciated. passed is set to false. XAML
Ram
  • 527
  • 1
  • 10
  • 26
-1
votes
1 answer

How to translate Xamarin Xaml IValueConverter into C#?

Can you please help me translate this Xamarin xaml into c#? BackgroundColor="{Binding IconColor, Converter={StaticResource LocalHexColorFromStringConverter}}"/> Thanks!
ScumSprocket
  • 347
  • 5
  • 16
-1
votes
2 answers

Invalid Cast Exception in MultiValueConverter Xamarin/WPF

While developing a MultiValueConverter I ran into an odd error. I am getting an 'Invalid Cast Exception' on the line: int frameSize = (int)values[0] ; // <-- thows InvalidCast Exception I honestly cannot determine why. public class SizeConverter :…
-1
votes
1 answer

Xamarin Forms - Get custom control runtime (with valueconverter?)

I have a Xamarin forms application. It has a page. That page has a listview. The listviews is bind to a sourcelist. What I want is to decide what custom control to use based on a specific property that each item in the list has. How can I achieve…
M Yil
  • 877
  • 1
  • 14
  • 35
-1
votes
1 answer

IValueConverter Using Lookup Collection

I am using a converter like this: public class BreedConverter : IValueConverter { static ObservableCollection Breeds = Breed_.GetBreeds(); public object Convert(object value, Type targetType, object parameter,…
DrTom
  • 29
  • 1
  • 7
-1
votes
1 answer

super Curstom value converters in Xamarin

I have a Xamarin forms app where I exhibit the result from different sensors all in one ListView. Every sensor populates a 'DataTemplate' ViewCell where I show the name, location and others and, in the central grid the values. The point is that the…
javirs
  • 1,049
  • 26
  • 52
-1
votes
1 answer

How to Bind a dynamic ListToString Converter to TextBlock In WPF C#

I Have a Textblock in a grid column which have different values like 2,4,1,0,3 etc. The values shows the quantity of students who belong to a play group activity as Cricket,BaseBall,Chess, BasketBall,Carrom etc. On Mouse Over a ToolTip is…
TechBrkTru
  • 346
  • 1
  • 25
-1
votes
1 answer

want to change background of textbox based on the input of another textbox wpf

i am trying to change the background of textbox based on the inputs of another textbox , like when i input "process" into one textbox the background of the other textbox should change to green. xmal code is
jithin
  • 45
  • 8
-1
votes
1 answer

Image Converter not working

Can anyone explain why I am getting the error: A generic error occurred in GDI+ Here is the code: [ValueConversion(typeof(System.Drawing.Image), typeof(ImageSource))] public class ImageConverter : IValueConverter { public object…
g.b
  • 85
  • 3
-1
votes
2 answers

WPF: How to get SelectedItem after applying value converter?

I have control where I bind the images. The code in my view model looks as following: public List SelectedEventPhotoList { get { return _selectedEventPhotoList; } set { if (Equals(value, _selectedEventPhotoList)) …
tesicg
  • 3,971
  • 16
  • 62
  • 121
-1
votes
2 answers

WPF datagrid Currency formatting Converter

I am trying to make a column in WPF datagrid to display currency in the following format: value <= 9999, display format set to $1,234; value <= 99999, display format set to $12k; value >99999, display format set to $12M; In addition, I would need…
OptimusPrime
  • 191
  • 1
  • 11
-1
votes
1 answer

WPF: Got Unable to cast object exception when try to convert

I try to convert simple string and add markup string for example: Value is: bla bla into: Value is bla bla So i want to use MultiValueConverter and add simple converter (so far without any implementation): public class…
Nuz reel
  • 19
  • 3
-1
votes
1 answer

Binding with IValueConverter does not work

I'm trying to binding the TextColor from a label on ViewCell: Label myLabel = new Label { Text = "SomeText" }; myLabel.SetBinding(Label.TextColorProperty, new Binding("TheTextColor", BindingMode.TwoWay, new LabelTextColorConverter())); Here's…
-1
votes
1 answer

Unable to find local resource XAML

In my user control XAML I am trying to use an IValueConverter .. I have a class named NullToBoolConverter which implements IValueConverter. I define my namespace like this: xmlns:local="clr-namespace:MyApp" In my UserControl.Resources, I am trying…
Sherlock
  • 5,557
  • 6
  • 50
  • 78
-1
votes
1 answer

How to transfer object to converter parameter in dynamic binding?

var b=new Binding(); b.Source=myobj; b.Path=new PropertyPath("Text",myParameter);//<-- myParemter is int value b.Converter=new FollConverter(); control.SetBinding(UserControl.VisibilityProperty,b); in my converter public object Convert(object…
ebattulga
  • 10,774
  • 20
  • 78
  • 116
1 2 3
44
45