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

WPF : An alternative way to specify a ValueConverter on binding

Most common way I encountered of specifying a value converter for a binding is to: 1. Create an instance of the value converter as a resource with a key. 2. Reference the instance using StaticResource markup extension:
THX-1138
  • 21,316
  • 26
  • 96
  • 160
2
votes
1 answer

Entity Framework Core 7 apply custom ValueConverter to Inserts and Updates

I am struggling to understand how to apply a custom ValueConverter to all the properties of all the models before every insert and update. According to this resource it can be…
sf84
  • 31
  • 4
2
votes
2 answers

EF Core - ValueConverter or OwnedType for simple ValueObjects?

I use value objects to encapsulate validations like maxLength. This is an extract of a sample class without factory method and validation: public class CallingName : ValueObject { public string Value { get; } public const int MaxLength =…
2
votes
1 answer

AutoMapper 8 ConvertUsing(Complex,string)

I am trying to clean a string EmailInstructions during a mapping but it fails when I call Mapper.Configuration.AssertConfigurationIsValid(); with: No coercion operator is defined between types 'System.String' and 'ElectionViewModel' Here's my…
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
2
votes
2 answers

Value Converter. Force WPF to call it only one time

let's say I have following code : So, I did not specified any binding information except Converter...Is it possible to force WPF to call it only one…
illegal-immigrant
  • 8,089
  • 9
  • 51
  • 84
2
votes
2 answers

Why do these two methods of loading images from SQL CE into a WPF Image produce different results?

In a ValueConverter, I was trying to convert a System.Data.Linq.Binary (SQL CE image) to a BitmapImage. This method works (image is show correctly on the form): public object Convert(object value, Type targetType, object parameter, …
Mark Carpenter
  • 17,445
  • 22
  • 96
  • 149
2
votes
1 answer

MVVMCross WPF Value Converter with Tibet Binding Is Not Converting?

I am trying to make a value converter which takes a bool and returns the negation of it. The value converter itself is simple: namespace MyProject.Core.ValueConverters { using System; using System.Globalization; using…
ms5991
  • 201
  • 2
  • 9
2
votes
1 answer

wpf converter in xaml

I know there are a few ways to use value converter in xaml, like using StaticResource to get converter from resources or Static to get from a static instance. My question is, for whatever reason, I have a converter instance created in the code…
Qstonr
  • 815
  • 1
  • 9
  • 11
2
votes
3 answers

Is using value converters to generate GUI-friendly strings a misuse of value converters?

Currently, I use value converters to generate user-friendly strings for the GUI. As an example, I have a window that displays the number of available entities in the status bar. The Viewmodel simply has an int dependency property that the calling…
tempy
  • 1,567
  • 2
  • 18
  • 28
2
votes
1 answer

Convert hex strings to integers

Visual Basic 2010: Recently in one of my projects I have been tasked with reading several data fields in hex. Each field is three characters long. So this is what I have been doing: 'Read the hex value and convert it to decimal Dim hexVal as string …
sinDizzy
  • 1,300
  • 7
  • 28
  • 60
2
votes
1 answer

Bind Image to ComboBox based on Object Enum Value

I have a Character Class that has an property Gender that is an Enum. What I want my code to do is to switch images based on what gender my Character is(if the character is male = male image). Where I am having the problem is how to correctly…
user2453973
  • 299
  • 1
  • 5
  • 21
2
votes
1 answer

WPF Value Converter Trigger Reconvertion at custom event?

Is there any way to force wpf to run the value converter again on a specific event?
Peter
  • 37,042
  • 39
  • 142
  • 198
2
votes
2 answers

Milliseconds since epoch to dateformat C++

I have the milliseconds since epoch (windows/gregorian) for a specific time in long long int and would like to convert it to human time such as yy-mm-dd-hh-mm-ss-milli. (My platform: Windows 7, 64bit) Unfortunately, all solutions I have found so far…
2
votes
3 answers

How to convert DataGridView Column from string to decimal?

I'm hoping to find a simple way to convert an entire column in my datagridview from a string data type to a decimal. Something simple like this maybe? DataGridView1.Columns(4).ValueType = Decimal
stackexchange12
  • 622
  • 9
  • 20
  • 41
2
votes
1 answer

Numeric Converter (big integers in string format)

I'm trying to write a class in C# that converts a big number (string format) to any number system, I found this code at How to convert a gi-normous integer (in string format) to hex format? (C#) var s = "843370923007003347112437570992242323"; …
hcaldera
  • 47
  • 4