<Image Source="{Binding Level,
Converter={StaticResource ExpanderIconConverter}}"
IsVisible="{Binding HasChildNodes,
Converter={StaticResource ExpanderIconVisibilityConverter},
ConverterParameter={x:Reference grid}}"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="35"
WidthRequest="35"/> |
public class ExpanderIconConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
if ((int)value == 0)
return ImageSource.FromResource("GettingStartedBound.Icons.collapse.png", assembly);
else if ((int)value == 1)
return ImageSource.FromResource("GettingStartedBound.Icons.plus.png", assembly);
else
return ImageSource.FromResource("GettingStartedBound.Icons.minus.png", assembly);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |
<treeview:SfTreeView x:Name="treeView"
ExpanderWidth="0"
Indentation="40"
ItemTemplateContextType="Node"
QueryNodeSize="TreeView_QueryNodeSize"
LoadOnDemandCommand="{Binding TreeViewOnDemandCommand}"
ItemsSource="{Binding Menu}">
<treeview:SfTreeView.ItemTemplate>
<DataTemplate>
<Grid x:Name="grid" Padding="5,5,5,5" RowSpacing="0" BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid RowSpacing="1"
Padding="1,0,0,0"
VerticalOptions="Center">
<Label LineBreakMode="NoWrap" TextColor="Black"
Text="{Binding Content.ItemName}" FontSize="20"
VerticalTextAlignment="Center">
</Label>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Source="{Binding IsExpanded, Converter={StaticResource ExpanderIconConverter}}"
IsVisible="{Binding HasChildNodes, Converter={StaticResource ExpanderIconVisibilityConverter}, ConverterParameter={x:Reference grid}}"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="35"
WidthRequest="35">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
</Image.GestureRecognizers>
</Image>
<Grid IsVisible="{Binding ShowExpanderAnimation, Mode=TwoWay}" RowSpacing="0">
<sfbusyindicator:SfBusyIndicator x:Name="grid1" IsVisible="True"
TextColor="{Binding Level, Converter={StaticResource IndicatorColorConverter}}"
IsBusy="True"
Margin="2" BackgroundColor="White"
ViewBoxHeight="25" ViewBoxWidth="25"
HeightRequest="32" AnimationType="SingleCircle"/>
</Grid>
</Grid>
</Grid>
</DataTemplate>
</treeview:SfTreeView.ItemTemplate>
</treeview:SfTreeView>
|