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

Efficiency of (multiple) MultiDataTrigger vs. Converter

I'm currently analyzing some XAML that uses style that make extensive use of MultiDataTriggers (8-10 multi data triggers per style, with 4-6 conditions per trigger). When looking at this I'm considering whether it would be more efficient to use a…
slugster
  • 49,403
  • 14
  • 95
  • 145
8
votes
1 answer

Converting Milliseconds to Days, hours, minutes and seconds

i have a bigint field in Microsoft SQL Server 2008R2 filled with ticks (A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a…
Christian Casutt
  • 2,334
  • 4
  • 29
  • 38
7
votes
3 answers

Aurelia - value converter using promise

I need to format Date using format returned by promise. I tried returning promise from toView(value). But that doesn't work. @autoinject export class DateTimeValueConverter { constructor(private formatService:FormatService) { } …
Juri Krainjukov
  • 732
  • 8
  • 27
7
votes
1 answer

C# How to convert Environment.TickCount into HH:mm:ss:ms

I'm trying to convert an int value Environment.TickCount into a format dd:HH:mm:ss:ms (days:hours:minutes:seconds:milliseconds) Is there an easy way to do it or should I divide Environment.TickCount by 60 then by 3600 then by 216000, etc ?
Fred Smith
  • 2,047
  • 3
  • 25
  • 36
7
votes
2 answers

Best approach for value conversion in KnockoutJS?

I have been trying to figure out the right approach to displaying/editing percentage values in Knockout-JS (and more generally how I should create reusable components like these). My ViewModel has an observable value which is a percentage stored as…
Quango
  • 12,338
  • 6
  • 48
  • 83
6
votes
3 answers

How to Convert string("1.0000") to int

The string format data with mostly 4 decimal places needs to be converted into int. I have tried this one but does not work and even directly using this Convert.ToInt16() but still did not worked: Int32 result; bool status = Int32.TryParse(v, out…
Jen143
  • 815
  • 4
  • 17
  • 42
5
votes
3 answers

EntityFrameworkCore is there a way to create EnumToStringConverter without passing the enum type as generic?

I am trying to use EntityFrameworkCore ORM to interact with my databases. By default, EntityFrameworkCore seems to store enum as int instead of string. However, I would like to store the value in the database as a string. I can see that…
Junior
  • 11,602
  • 27
  • 106
  • 212
5
votes
8 answers

Converting a year string i.e. '2005' to a Datetime value

I am creating a simple input form to create an account. On the form there is an input field for the year the company was founded, this is a simple textbox where the user will type in the year i.e. 2005. However on attempting to insert this to the…
Paul Kirkason
  • 227
  • 2
  • 4
  • 20
5
votes
1 answer

is it a bad idea to have static wpf value converters?

Instead of declaring the converter in the Resources, i can do something like IsEnabled={Binding Path=SomeProp, Converter={x:Static namespace:Converter.Instance}}" where Instance is instantiated only once (lazy sinlgeton) But i'm worried about…
5
votes
2 answers

Are value converters instantiated per-binding in WPF?

Is a separate WPF value converter object instantiated for each binding that a particular value converter class is used in? I am trying to create a two-way bit-to-boolean value converter. I would like to be able to bind a bool property (such as…
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
4
votes
3 answers

Is the 'Self' construct useful in Silverlight/MVVM?

I've inherited a Silverlight project with dubious code quality overall, and there is one construct that I'm not sure whether I should touch it: public SomeClass Self { get { return this; } } It is used in XAML Bindings, with…
jv42
  • 8,521
  • 5
  • 40
  • 64
4
votes
1 answer

How to use reference converter within a resource dictionary

I've created a multibinding converter (ListItemDescriptionConverter) that will combine several values into a single string as output for ListBox items. However I don't know how to get the resource dictionary to point to the converter class in a…
ChrisUK
  • 547
  • 8
  • 17
4
votes
3 answers

Pandas DataFrame: Cannot convert string into a float

I have a column Column1 in a pandas dataframe which is of type str, values which are in the following form: import pandas as pd df = pd.read_table("filename.dat") type(df["Column1"].ix[0]) #outputs 'str' print(df["Column1"].ix[0]) which outputs…
ShanZhengYang
  • 16,511
  • 49
  • 132
  • 234
4
votes
2 answers

WPF Multiple Enum Flags to Converter Parameter?

I have a control which I need visible if an enum value is (A | B | C). I know how to bind the visibility of a control to a SINGLE enum (A) using a converter. How do I go about doing the same for this case? What would go in the parameter? This is…
Will
  • 3,413
  • 7
  • 50
  • 107
4
votes
2 answers

How to use ResourceDictionary as StaticResource in Windows Phone 8

I have a Windows Phone 7 app which I'm trying to create a Windows Phone 8 version of it. In the app I have a ResourceDictionary defined in a XAML file as:
TheBlueSky
  • 5,526
  • 7
  • 35
  • 65
1
2
3
14 15