I have implemented the tree view. But I am facing a new challenge.
I want to create child elements after clicking the plus sign. The child
elements can only be created until level 3.
The hierarchy is as follows:
What I want to do is, create Feature by clicking the plus and so on. But “Task”, the lowest level cannot have a child.
<Image Source="{Binding Content.AddIcon}"
IsVisible="{Binding Level, Converter={StaticResource ExpanderIconVisibilityConverter}}" /> |
public class ExpanderIconVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value == 3 ? false : true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |
<Image Source="{Binding Content.AddIcon}"
Grid.Column="1"
IsVisible="{Binding Level, Converter={StaticResource IconVisibilityConverter}}"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="35"
WidthRequest="35">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.AddImageClickedCommand, Source={x:Reference treeView}}" CommandParameter="{Binding .}"/>
</Image.GestureRecognizers>
</Image> |
private void OnAddImageClickedCommand(object obj)
{
var node = obj as TreeViewNode;
var musicInfo = node.Content as MusicInfo;
App.Current.MainPage.DisplayAlert("Add icon clicked", "ID " + musicInfo.ID, "OK");
//if(musicInfo.ID == 1)
//go to page 1
//if (musicInfo.ID == 2)
//go to page 1
//if (musicInfo.ID == 3)
//go to page 1
} |