<ContentPage.Resources>
<ResourceDictionary>
<OnPlatform x:TypeArguments="x:String" x:Key="ExpanderIcon">
<On Platform="Android" Value="ExpanderIcons.ttf#ExpanderIcons" />
<On Platform="UWP" Value="/Assets/ExpanderIcons.ttf#ExpanderIcons" />
<On Platform="iOS" Value="ExpanderIcons" />
</OnPlatform>
</ResourceDictionary>
<local:ExpanderIconConverter x:Key="ExpanderIconConverter"/>
<local:ExpanderVisibilityConverter x:Key="ExpanderVisibilityConverter"/>
</ContentPage.Resources>
<syncfusion:SfExpander x:Name="expander1" HeaderIconPosition="None">
<syncfusion:SfExpander.Header>
<Grid HeightRequest="50">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label HorizontalOptions="Center" VerticalOptions="Center"
FontFamily="{StaticResource ExpanderIcon}"
IsVisible="{Binding Path=IsExpanded, Source={x:Reference expander1}, Converter={StaticResource ExpanderVisibilityConverter}, ConverterParameter=Header}"
Text="{Binding Path=IsExpanded,Source={x:Reference expander1}, Converter={StaticResource ExpanderIconConverter}, ConverterParameter={x:Static Device.RuntimePlatform}}"/>
<Label Text="Veg Pizza" Grid.Column="1" TextColor="#495F6E" VerticalTextAlignment="Center" />
</Grid>
</syncfusion:SfExpander.Header>
<syncfusion:SfExpander.Content>
<Grid BackgroundColor="#FFFFFF">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label HorizontalOptions="Center" VerticalOptions="Center"
FontFamily="{StaticResource ExpanderIcon}"
IsVisible="{Binding Path=IsExpanded,Source={x:Reference expander1}, Converter={StaticResource ExpanderVisibilityConverter}, ConverterParameter=Content}"
Text="{Binding Path=IsExpanded,Source={x:Reference expander1}, Converter={StaticResource ExpanderIconConverter}, ConverterParameter={x:Static Device.RuntimePlatform}}"/>
<Label BackgroundColor="#FFFFFF" HeightRequest="50" Grid.Column="1" Text="Veg pizza is prepared with the items that meet vegetarian standards by not including any meat or animal tissue products." TextColor="#303030" VerticalTextAlignment="Center"/>
</Grid>
</syncfusion:SfExpander.Content>
</syncfusion:SfExpander> |
public class ExpanderVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((string)parameter == "Header")
return (bool)value ? false : true;
else
return (bool)value ? true : false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |