Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
150490 | Jan 9,2020 02:12 AM UTC | Jan 10,2020 05:47 AM UTC | Xamarin.Forms | 4 |
![]() |
Tags: SfTreeView |
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
} |
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.