Questions tagged [valueconverter]

Value converters are culture-aware. Both the Convert and ConvertBack methods have a culture parameter that indicates the cultural information.

Value converters are culture-aware. Both the Convert and ConvertBack methods have a culture parameter that indicates the cultural information.

Ref: IValueConverter

216 questions
3
votes
3 answers

Creating a WPF ValueConverter for a Brush

On the Nerd Plus Art blog today, there was a post about creating WPF Resources for arrows, which the author uses frequently. I have a side project that has Back and Forward buttons, so I thought that the Left and Right arrows would work great on…
Andy
  • 30,088
  • 6
  • 78
  • 89
3
votes
1 answer

Combining ValidationRule and Value Converters for a textbox

I have a simple problem that I just cant find a good solution for. I have a textbox bound to a double property value. The user can enter values into the textbox, but I only want to allow values between 0 and 100. I would like to show a red box…
Peter
  • 31
  • 1
3
votes
1 answer

How to use a codebehind variable as input to ConverterParameter in ValueConverter

I have a ListBox where I set the ItemsSource to a CollectionViewSource that is populated from a WCF service. I use a value converter in the ListBox.ItemTemplate\DataTemplate to convert a property on the objects in the ItemsSource. This all works as…
Gern Blanston
  • 42,482
  • 19
  • 50
  • 64
3
votes
1 answer

IValueConverters and MockData

I am trying to create an IValueConverter that takes an enum and spits out a URI. The converter does work at runtime as expected. However the XAML Designer trows me an error saying: Object must be the same type as the enum. The type passed in was…
EnvelopedDevil
  • 658
  • 1
  • 13
  • 29
3
votes
2 answers

How to pass the current row "This" as to a converter parameter

So I have a view, containing a telerik RadGridView, this view is bound to several items, but importantly I need to bind the visibility of an item in one column, to 2 items. The converter will correctly evaluate the visility, however I need to pass…
asuppa
  • 571
  • 1
  • 11
  • 27
3
votes
1 answer

Why during conversion to single I lost the point (13.5 becomes 135)?

I use just simple code but I cannot understand the reason of mistake Console.WriteLine(Convert.ToSingle("13.5")); output 135 Why??
user4385235
3
votes
3 answers

How to open one view from another view using MVVM in WPF

I am new to MVVM. And i am not able to get answer of this problem since a long time. I don't know if question is so difficult or i have not explained properly. I have MainWindow.Xaml which contains a textblock and a button to receive the data from…
struggling
  • 535
  • 1
  • 10
  • 25
3
votes
1 answer

In C#, why is this conversion causing an "Input string was not in a correct format." error?

I have code that reads a number (but comes in as a string) and i am trying to convert it to a byte. Normally the value is between 0 and 1 (like .25) and my code below works fine but I now came across a negative value, in particular "-1" and trying…
leora
  • 188,729
  • 360
  • 878
  • 1,366
3
votes
0 answers

IDataErrorInfo with ValueConverter

I'm somehow doing it wrong, but I can't figure it out: I have a model like this: public class Person : IDataErrorInfo { public DateTime Birthdate { get { return _birthdate; } set { if (!Valid(value)) AddError("Birthdate",…
3
votes
2 answers

Apply value converter in XAML without databinding

I have a TextBlock in my view that I want to always display the number 1, converted into the local currency. (e.g. $1 in US, £1 in UK, etc). I have a value converter that can do this, but I don't know how to apply a value converter to the value of 1…
Nick Udell
  • 2,420
  • 5
  • 44
  • 83
3
votes
1 answer

Converter of System.Drawing.Point' to 'System.Windows.Point

I am trying to draw few entities in WPF. My collection contains System.Drawing.Rectangle objects, When I try to access the location of those objects in WPF XAML I am getting following error Cannot create default converter to perform 'one-way'…
RobinAtTech
  • 1,299
  • 3
  • 22
  • 48
3
votes
2 answers

MVVMCross MvxBind, binding multiple values to one property

How do I use a combination of booleans values, to set the enabled property on a MvxBind button? For example: Using one boolean value, the binding is achieved with:
3
votes
3 answers

WPF Singleton ValueConverters performance implications

I have been consistently using Singleton value converters in WPF. But recently I got into an argument with a colleague where he was saying like it is bad to use singleton instance of valueconverters as they would be disposed only by the app domain…
3
votes
2 answers

Converting a base 31 value to BigInt in SQL Server

In our DB we use a primary key for everything that is a combination of the digits 0 through 9 and all the letters in the alphabet that are not vows. the letter Y is included. I created this table to organize it. CREATE Table Base31 (ID varchar(1), …
Joe
  • 55
  • 5
3
votes
6 answers

converting timestamp to date in java

This is my database: Here I have to check the query current date+status=Q information and get the count value. This is my code: public class TodayQ { public int data() { int count=0; Date date = new Date(timestamp); DateFormat…
Krishna Veni
  • 2,217
  • 8
  • 27
  • 53
1 2
3
14 15