【发布时间】:2019-12-27 05:04:37
【问题描述】:
我正在与SyncFusion's TreeView 合作。我有一个带有三个单独的数据模板/自定义视图单元的 TreeView。在我的主 XAML 中,我有以下绑定到我的 DataTemplates 的树视图代码。
SamplePage.xaml
<syncfusion:SfTreeView x:Name="treeView"
QueryNodeSize="TreeView_QueryNodeSize"
NodeSizeMode="Dynamic"
AutoExpandMode="RootNodesExpanded"
ChildPropertyName="SubFiles"
ItemsSource="{Binding ImageNodeInfo}" Indentation="0"
ItemTemplate="{StaticResource TemplateSelector}">
</syncfusion:SfTreeView>
我现在正在尝试将我的命令从我的一个数据模板(下面的代码)绑定到连接到我的页面的视图模型,但我似乎无法连接我的数据绑定。大多数在线示例在视图/视图模型的同一 xaml 页面上显示数据模板。然而,我的代码使用了一个数据模板选择器,这给了我一个更难绑定的路径。
SampleTemplate.xaml
<ViewCell.BindingContext>
<local:SamplePage x:Key="SamplePage">
</local:SamplePage>
</ViewCell.BindingContext>
<ImageButton Aspect="AspectFill"
Grid.Row="0" Grid.Column="3"
HorizontalOptions="End"
WidthRequest="90" HeightRequest="90"
Source="{xaml:ImageResource plus_Icon}"
Command="{Binding Path=BindingContext.AddAsJobClickedCommand}, Source={x:Reference SamplePage}"
CommandParameter="{Binding treeView}"
/>
【问题讨论】:
标签: c# xamarin xamarin.forms prism syncfusion