如何在Syncfusion的TreeView上触发点击事件

问题描述 投票:0回答:3

Menu.xaml

<MasterDetailPage.Master>
    <ContentPage Title="Menu" Padding="0">
        <ContentPage.Content>
            <StackLayout>
                <Grid BackgroundColor="LightGreen">
                    <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="10"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="80"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="10"/>
                        </Grid.RowDefinitions>
                        <Label Grid.Column="1"
                               Grid.Row="2"
                               Text="DEC App"
                               TextColor="White"
                               FontSize="Large"/>
                    </Grid>
                    <syncfusion:SfTreeView x:Name="treeView">
                        <syncfusion:SfTreeView.Nodes>
                            <!--1st Menu-->
                            <treeviewengine:TreeViewNode Content="Menu 1">
                                <treeviewengine:TreeViewNode.ChildNodes>
                                    <treeviewengine:TreeViewNode Content="Menu 1.1">
                                        <!--SubMenu 1-->
                                    </treeviewengine:TreeViewNode>
                                    <treeviewengine:TreeViewNode Content="Menu 1.2">
                                        <!--SubMenu 2-->
                                        <treeviewengine:TreeViewNode.ChildNodes>
                                            <treeviewengine:TreeViewNode Content="Menu 1.2.1"/>
                                            <!--SubMenu 2.1-->
                                            <treeviewengine:TreeViewNode Content="Menu 1.2.2"/>
                                            <!--SubMenu 2.2-->
                                        </treeviewengine:TreeViewNode.ChildNodes>
                                    </treeviewengine:TreeViewNode>
                                </treeviewengine:TreeViewNode.ChildNodes>
                            </treeviewengine:TreeViewNode>
                        </syncfusion:SfTreeView.Nodes>
                    </syncfusion:SfTreeView>
                </StackLayout>
            </ContentPage.Content>
        </ContentPage>
    </MasterDetailPage.Master>
</MasterDetailPage>

Menu.xaml.cs

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace MasterDetailDemo
{
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class Menu : MasterDetailPage
{
    public Menu()
    {
        InitializeComponent();
        Detail = new NavigationPage(new MenuDetail());
    }

我使用Syncfusion的SfTreeView在这里创建此菜单

TreeView in Master Page Demo

但是我不知道如何在其上创建click事件,我尝试通读Syncfusion的所有文档,但并没有太大帮助。在此先感谢

xamarin.forms treeview syncfusion
3个回答

0
投票

我们想通知您,当在视图中单击树视图节点时,可以使用TreeView的ItemTapped事件或TapCommand来获取通知。我们随附了示例和代码段,供您在下面参考。


0
投票

首先,将ItemTapped事件添加到syncfusion:SfTreeView

© www.soinside.com 2019 - 2024. All rights reserved.