ivalueconverter

Dependency propery for ValueConverter or rebind control?

Hi all, I have custom control with some text in content template: <ControlTemplate TargetType="{x:Type local:TouchScreenKey}"> <TextBlock><ContentPresenter Content="{TemplateBinding Title, Converter={StaticResource CaseConverter}}" /></TextBlock> </ControlTemplate> and custom IValueConverter CaseConverter - with property Upper...

What is the best practice for WPF ValueConverter error handling?

Two function should be implemented, and I am wondering what type of validation I need to do on inputs and how to manage errors. Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConve...

Refreshing a binding that uses a value converter

I have a WPF UI that is bound to an object. I'm using a ValueConverter to convert a property to a specific image by a business rule: public class ProposalStateImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var proposal...

Is there a way to chain multiple value converters in XAML?

I've got a situation in which I need to show an integer value, bound to a property on my data context, after putting it through two separate conversions: Reverse the value within a range (e.g. range is 1 to 100; value in datacontext is 90; user sees value of 10) convert the number to a string I realise I could do both steps by creati...

WPF performance : Converters vs. Triggers

hi there, i´m currently facing a problem where i have to set properties on a bunch of framework elements depending on some other properties. i wonder how triggers and converters compare when it comes to performance. Especially MultiTriggers and IMultiValueConverters. Is there any difference? google wasn't helpful so i thought maybe so...

Telerik RadGridView problem

I am using Telerik RadGridView in my project. I want to show image in column. GridViewImageColumn col1 = new GridViewImageColumn(); col1.Width = 100; col1.DataMemberBinding = new Binding("id"); col1.Header = "PhotoByConverter"; col1.DataMemberBinding.Conver...

Why do I get a DependencyProperty.UnsetValue when converting a value in a MultiBinding?

I have an extremely simple IMultiValueConverter that simply OR's two values. In the example below, I want to invert the first value using an equally simple boolean inverter. <MultiBinding Converter="{StaticResource multiBoolToVis}"> <Binding Path="ConditionA" Converter="{StaticResource boolInverter}"/> <Binding Path="ConditionB"...

Why do we need to use ConvertBack in IValue Converter

Hi, I am not sure Why we need to use I ConvertBack method in IValueConverter. In the Convert method itself we do the conversion and return the updated value to be bound in our control. So in which Scenario we should use Convertback. I know this question is very basic but just wanted to make the fundamentals clear. Thanks a lot for you...

WPF - Getting PropertyName in IValueConverter

I'm playing around with WPF and databinding and I'm wondering about the following. I defined a few PropertyGroupDescriptions, but now I'm wondering how to read the PropertyName from an IValueConverter. Is this possible? ...

Why does my IMultiBindingConverter get an array of strings when used to set TextBox.Text?

Hi- I'm trying to use a MultiBinding with a converter where the child elements also have a converter. The XAML looks like so: <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource localizedMessageConverter}" ConverterParameter="{x:Static res:Resources.RecordsFound}" > <Binding Converter="{StaticResource lo...

DataContext as Source for Converter Binding Within Resources

<Canvas.DataContext> <ViewModels:VMSomeControl Model="{Binding RelativeSource={RelativeSource TemplatedParent}}" /> </Canvas.DataContext> <!-- DataContext is not passed into these Instances. they also have no knowledge of their TemplatedParent. --> <Canvas.Resources> <!-- is there a way to use a binding t...

where does IValueConverter.Convert source the CultureInfo parameter from?

I'm going through some silverlight apps and reviewing date formatting to make sure the presentation is appropriate for the viewer. with an implementation of IValueConverter, where does the culture parameter come from in the Convert/ConvertBack functions? it seems to not be CultureInfo.CurrentCulture which I think is what I want. ...

WPF Converter and NotifyOnTargetUpdated exclusive in a binding ?

Hi, I have a problem with a databinding in WPF. When I try to use a value converter and set the NotifyOnTargetUpdated=True property to True, I get an XamlParseException with the following message: 'System.Windows.Data.BindingExpression' value cannot be assigned to property 'Contenu' of object 'View.UserControls.ShadowedText'....

WPF Converter with Property vs MultiConverter?

What is the difference between using a Converter (IValueConverter) and passing in other values as parameters (ConverterParameter) vs using a MultiConverter (IMultiValueConverter) and just passing in multiple converter values? ...

What should you use IValueConverter for?

What are the recommended uses of IValueConverter? I've used it for things like converting a boolean property to a Visibility property but I'm wondering how far you should take it? Is it supposed to be only used to change representations of common types to UI specific types (bool to Visibility for example). E.g., if I have a property i...

Binding to FontWeight in Silverlight 4 using a value converter

I want to compare two versions of various properties and bold one of them if it is not equal to the other. Since SL4 doesn't support MultiBinding I am binding the FontWeight to "." so that the entire data context is passed to the converter. I then use the converter parameter to specify which fields to compare within the converter. So f...

WPF BooleanToVisibilityConverter that converts to Hidden instead of Collapsed when false?

Is there a way to use the existing WPF BooleanToVisibilityConverter converter but have False values convert to Hidden instead of the default Collapsed, or should I just write my own? I'm on a project where it's tremendous overhead to do something simple like this (shared stuff goes into a separate solution, and the rebuild/checkin/merge...

WPF: InotifyPropertyChanged, IValueConverter, & background threads

let's say we are using IValueConverter to format a GridView cell background color depending on its value. now let's say that value is calculated on a separate thread, after adding the item to the collection. var args = GetInput(); if (ValidateArgs(args)) { if (args.Rate.HasValue) Thre...

Howto observe converted collections?

I bind a collection ObservableCollection<Foo> to a dependency property on my controller, but I run it through an IValueConverter to make it ObservableCollection<object> instead, which is what my controller expect. The conversion works fine - I create an ObservableCollection<object> and fill it with all the Foo's from the original list. T...

using converters

I have to format a string ("00:10:08:10") into (10 weeks 08 days 10 hrs). So I used a converter and added it with the datagrid binding. My code: Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Wind...