user20564490
user20564490

Reputation:

.NET MAUI 7 - SwipeView inaccessible in code-behind

The SwipeView is in a CollectionView, that is accessible via its x:Name attribute. But I cannot access the SwipeView via its x:Name:

<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."

Upvotes: 1

Views: 391

Answers (1)

Alexandar May - MSFT
Alexandar May - MSFT

Reputation: 10158

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.

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

Upvotes: 1

Related Questions