![](/img/trans.png)
[英]How can I make a ContentPage with a StackLayout inside scrollable?
[英]How to make button inside a stacklayout clickable but make the rest of the items and the stacklayout not clickable?
我有一個包含許多元素的堆棧布局,其中一個是按鈕。 我希望能夠單擊此按鈕,但是我希望其中的其他元素(以及堆棧布局本身)為IsEnabled
false。
該堆棧布局位於地圖的頂部,因此用戶可以在其頂部使用地圖的基本功能非常重要。
現在我有這樣的事情(我刪除了其中的所有屬性以使代碼更易讀)
<StackLayout IsEnabled = "false" >
<Image />
<Label />
<Button Clicked = "ClickEvent" />
</StackLayout>
因此,現在我將堆棧設置為IsEnabled
false,這使其在地圖頂部時無法單擊,這很好,但是現在無法單擊我的按鈕。
我如何解決這個問題?
嘗試改用InputTransparent
設置InputTransparent僅會禁用輸入,而是導致將它們傳遞到元素后視覺上可見的VisualElement。
您不能只使用XAML元素的z-index嗎? 將其包裝在另一個容器(例如StackLayout
或Grid
)中,如下所示:
<StackLayout>
<StackLayout IsEnabled = "false" >
<Image />
<Label />
</StackLayout>
<Button Clicked = "ClickEvent" />
</StackLayout>
這將在StackLayout
上方顯示Button
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.