![](/img/trans.png)
[英]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.