Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to get instance of bound object?

$
0
0

I have a ContentPage defined in .xaml that contains a ListView.

<ListView ItemsSource="{Binding Groups}" 
        IsGroupingEnabled="true" 
        GroupDisplayBinding="{Binding Title}"
        HasUnevenRows="true">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <yds:ZonesPagesItem/>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
</ListView>

This ListView contains items that are ContentViews (see above : yds.ZonesPagesItem), defined in another xaml :

<ContentView (...)>
    <StackLayout Orientation="Horizontal" > 
        <Image Source="{Binding ImageUrl}" />
        <Label Text="{Binding Title}"></Label>
    </StackLayout>
</ContentView>

In my Xaml ContentView, I can "bind" to bound object properties succesfully.
But I also need to manipulate programatically the bound object in c# code behind code. My problem is that I don't know how to get instance of bound object in C# side.

public partial class ZonesPagesItem : ContentView
{
    public ZonesPagesItem()
    {
        InitializeComponent();

        var boundObject = this.GetBoundObject();
        // Do some business logic job wih boundObject...
        // It does not compile! GetBoundObject() does not exist.
    }
}

See upper, I wish GetBoundObject() method exists!
This is what I'm looking for.
Any idea?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>