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

Databinding question

$
0
0

I have a CollectionView that is populated with a ObservableCollection of Class objects. I also have a button that retrieves the SelectedItem and I was wondering if there's a way to transfer the databinding setting from the SelectedItem to my ClassInfoPage that is opened via that same button. My goal is to have the ClassInfoPage bindingcontext be the same Class Object that my SelectedItem uses for binding.
ClassInfoButton click event

private async void ClassInfoButton_OnClicked(object sender, EventArgs e)
{

    FlexLayout selectedClass = ClassesCollectionView.SelectedItem as FlexLayout;
    await Navigation.PushAsync(new ClassInfoPage());
}

CollectionView that my class objects are loaded in

 <CollectionView ItemsSource="{Binding Classes}" x:Name="ClassesCollectionView" SelectionMode="Single" HeightRequest="0">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <FlexLayout Direction="Row" AlignItems="Center" JustifyContent="SpaceEvenly" HeightRequest="35">
                        <Label Text="{Binding ClassName}" FontSize="Micro"/>
                        <Label Text="{Binding ClassStatus}" FontSize="Micro"/>
                        <DatePicker Date="{Binding ClassStartDate}" FontSize="Micro"/>
                        <DatePicker Date="{Binding ClassEndDate}" FontSize="Micro"/>
                    </FlexLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

If there's any additional info you need, feel free to ask. Thanks in advance.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



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