[英]Maui Collection View: Need to access sibling controls in code-behind
[英].NET MAUI 7 - SwipeView inaccessible in code-behind
SwipeView 位于 CollectionView 中,可通过其 x:Name 属性访问。 但我无法通过其 x:Name 访问 SwipeView:
<SwipeView x:Name="swipe">
<SwipeView.RightItems>
<SwipeItems >
<SwipeItem />
</SwipeItems>
</SwipeView.RightItems>
<Label Text="SomeText"/>
</SwipeView>
当我尝试在后面的代码中执行“swipe.IsEnabled”时,它显示“当前上下文中不存在名称‘swipe’。”
正如 Jason 所建议的,您可以使用数据绑定来设置SwipeView
的IsEnabled
,如下所示,然后控制ViewModel
或代码隐藏中的属性。
<SwipeView IsEnabled="{Binding IsSwipeViewEnabled}">
<SwipeView.RightItems>
<SwipeItems >
<SwipeItem />
</SwipeItems>
</SwipeView.RightItems>
</SwipeView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.