This is a migrated thread and some comments may be shown as answers.

Using {Binding .} with value converters

6 Answers 900 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Gerry
Top achievements
Rank 1
Gerry asked on 23 Feb 2017, 03:27 PM

Re: telerikDataControls:RadListView
Re: Binding, Converter
Re: accessing object in code behind

See also: https://forums.xamarin.com/discussion/54042/using-binding-with-value-converters

It seems that the converter should have access to the "object" from the list (recall that a RadListView gets it's data from a list of objects). The proper notation appears to be like:

<Label Text="{Binding Path=., Converter={StaticResource stateConverter}, ConverterParameter='some parameter'}" />

The converter looks like:

public object Convert(object obj, Type targetType, object parameter, CultureInfo culture)

But "obj" is always null. How can I access the object in the converter?

Thanks!

6 Answers, 1 is accepted

Sort by
0
Lance | Senior Manager Technical Support
Telerik team
answered on 23 Feb 2017, 09:35 PM
Hello Gerry,

If the Label you're showing below is in the RadListView's ItemTemplate, this is the syntax you're looking for.

<Label Text="{Binding Converter={StaticResource stateConverter}, ConverterParameter='some parameter'}" />

This will pass the BindingContext of that DataTemplate to the value parameter of the converter.

For example, if your RadListView was bound to an ObservableCollection<Car>, your converter would work  like this:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
    var car = value as Car;
}


Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Gerry
Top achievements
Rank 1
answered on 24 Feb 2017, 03:12 PM
Thanks, I was able to extend the "SongPage" related example code and get a converter working
0
Kiril
Top achievements
Rank 1
answered on 19 Jan 2018, 11:23 AM
I keep seeing these binding examples that are more complex than simple {{ modelVariableName }} but besides discussion of the pipes there's nothing in the documentation.  Where can we find more information about more involved usage like above? 
0
Lance | Senior Manager Technical Support
Telerik team
answered on 19 Jan 2018, 07:23 PM
Hello Kiril,

Looking at the syntax that you used, I suspect you're referring to Angular or Vue and using Kendo UI?  This thread is about UI for Xamarin and Xamarin.Forms XAML.

- For Vue, find the Vue documentation here and
- For Angular, find the Angular documentation here.

If you did intend to post to the Xamarin topic, find the Xamarin Data Binding Documentation here (we don't have documentation for general programming topics like data binding).

If you wanted to post to the Kendo forums about a specific implementation, find a list of our forums here.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Kiril
Top achievements
Rank 1
answered on 20 Jan 2018, 06:53 AM

Hey Lance,

i'm actually struggling with the NativeScript DataForm.  I guess Telerik in your signature through me off.

My apologies.

0
Lance | Senior Manager Technical Support
Telerik team
answered on 22 Jan 2018, 04:39 PM
Hello Kiril,

No worries. I just want to make sure you get the assistance you need in a timely manner. I think this is the information you were looking for: Using Converters in Bindings (NativeScript).

Here are some additional links for you to bookmark that I think will be helpful for you:

NativeScript Forums
DataBinding Documentation
ListView Overview Documentation


I don't see a NativeScript support license in your account, so I can't direct you towards opening a support ticket. However, if you are using an enterprise license that has support, you can have your employer/manager assign you as one of the Licensed Users here in the Manage Licensed Users Portal.

Once you're assigned as a Licensed User, you can open Support Tickets here.

I hope I was able to answer your question, if you have any additional questions, you can post in the NativeScript forums (link above).

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
Gerry
Top achievements
Rank 1
Answers by
Lance | Senior Manager Technical Support
Telerik team
Gerry
Top achievements
Rank 1
Kiril
Top achievements
Rank 1
Share this question
or