簡體   English   中英

.NET MAUI 7 - 在代碼隱藏中無法訪問 SwipeView

[英].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 所建議的,您可以使用數據綁定來設置SwipeViewIsEnabled ,如下所示,然后控制ViewModel或代碼隱藏中的屬性。

<SwipeView IsEnabled="{Binding IsSwipeViewEnabled}">
    <SwipeView.RightItems>
        <SwipeItems >
            <SwipeItem />
        </SwipeItems>
    </SwipeView.RightItems>
    
</SwipeView>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM