Using {Binding .} with value converters

7 posts, 0 answers
  1. Gerry
    Gerry avatar
    34 posts
    Member since:
    Jan 2017

    Posted 23 Feb 2017 Link to this post

    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!

  2. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1195 posts

    Posted 23 Feb 2017 Link to this post

    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
  3. Gerry
    Gerry avatar
    34 posts
    Member since:
    Jan 2017

    Posted 24 Feb 2017 in reply to Lance | Manager Technical Support Link to this post

    Thanks, I was able to extend the "SongPage" related example code and get a converter working
  4. Kiril
    Kiril avatar
    6 posts
    Member since:
    Dec 2017

    Posted 19 Jan 2018 Link to this post

    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? 
  5. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1195 posts

    Posted 19 Jan 2018 Link to this post

    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
  6. Kiril
    Kiril avatar
    6 posts
    Member since:
    Dec 2017

    Posted 20 Jan 2018 in reply to Lance | Manager Technical Support Link to this post

    Hey Lance,

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

    My apologies.

  7. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1195 posts

    Posted 22 Jan 2018 Link to this post

    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
Back to Top