[英].NET MAUI 7 - SwipeView inaccessible in code-behind
The SwipeView is in a CollectionView, that is accessible via its x:Name attribute. SwipeView 位于 CollectionView 中,可通过其 x:Name 属性访问。 But I cannot access the SwipeView via its x:Name:但我无法通过其 x:Name 访问 SwipeView:
<SwipeView x:Name="swipe">
<SwipeView.RightItems>
<SwipeItems >
<SwipeItem />
</SwipeItems>
</SwipeView.RightItems>
<Label Text="SomeText"/>
</SwipeView>
When I try to do 'swipe.IsEnabled' in the code behind, it displays "The name 'swipe' doesn't exist in the current context."当我尝试在后面的代码中执行“swipe.IsEnabled”时,它显示“当前上下文中不存在名称‘swipe’。”
Just as Jason suggested, you can use data binding to set the IsEnabled
of the SwipeView
like below and then control the property in your ViewModel
or Code-behind.正如 Jason 所建议的,您可以使用数据绑定来设置SwipeView
的IsEnabled
,如下所示,然后控制ViewModel
或代码隐藏中的属性。
<SwipeView IsEnabled="{Binding IsSwipeViewEnabled}">
<SwipeView.RightItems>
<SwipeItems >
<SwipeItem />
</SwipeItems>
</SwipeView.RightItems>
</SwipeView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.