Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
149826 | Dec 11,2019 08:19 AM UTC | Dec 16,2019 05:38 AM UTC | Xamarin.Forms | 4 |
![]() |
Tags: SfAccordion |
Xaml
<syncfusion:SfAccordion x:Name="Accordion" ExpandMode="MultipleOrNone" BindableLayout.ItemsSource="{Binding Info}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<syncfusion:AccordionItem IsExpanded="{Binding IsExpand}">
<syncfusion:AccordionItem.Header>
<Label Text="{Binding Name}"/>
</syncfusion:AccordionItem.Header>
<syncfusion:AccordionItem.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Label Text="{Binding Description}"/>
<Button x:Name="btn" Grid.Row="1" Text="{Binding Name}" Command="{Binding Path=BindingContext.ButtonCommand, Source={x:Reference Accordion}}" CommandParameter="{x:Reference btn}"/>
</Grid>
</syncfusion:AccordionItem.Content>
</syncfusion:AccordionItem>
</DataTemplate>
</BindableLayout.ItemTemplate>
</syncfusion:SfAccordion>
ViewModel.cs
public class ItemInfoRepository : INotifyPropertyChanged
{
public ObservableCollection<ItemInfo> Info { get; set; }
public Command<object> ButtonCommand { get; set; }
public ItemInfoRepository()
{
Info = new ObservableCollection<ItemInfo>();
ButtonCommand = new Command<object>(OnButtonTapped);
}
private void OnButtonTapped(object obj)
{
var item = (obj as Button).BindingContext as ItemInfo;
item.IsExpand = !item.IsExpand;
}
}
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.