[英]Xamarin.Forms how use Xamarin Community Toolkit TouchEffect in VisualState
我正在使用 VisualState 在我的 XAML 中實現一個條件,但我不知道如何在 VisualState 中更改 Xamarin Community Toolkit TouchEffect 等效果的屬性,有什么建議嗎?
<StackLayout HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
BackgroundColor="Red"
HeightRequest="200">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="test">
<VisualState.StateTriggers>
<CompareStateTrigger Property="{Binding sampleBool}" Value="true" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!--Here in the Property there should be some way to refer to the Command property of the TouchEffect-->
<Setter Property="xct:TouchEffect.Command" Value="{Binding sampleCommand}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</StackLayout>
我嘗試過以這種方式引用,但它引發了以下錯誤:x:Static: 無法找到公共的——或可訪問的內部——static 字段,ZA81259CEF8E959C624ZZZDF1D456E5D329 屬性中的“x:Z81259CEF8E959C624ZZDF1D456E5D329”命令觸控效果”。
<Setter Property="{x:Static xct:TouchEffect.Command}" Value="{Binding sampleCommand}" />
我也嘗試使用 Type,但出現此錯誤:無法解析類型“TouchEffect.Command”
<Setter Property="{x:Type xct:TouchEffect.Command}" Value="{Binding sampleCommand}" />
這是正確的方法,我的問題是因為其他原因,我在 DataTemplate 中有代碼,必須引用頁面視圖 model。
在正常情況下,這將起作用:
<Setter Property="xct:TouchEffect.Command" Value="{Binding sampleCommand}" />
就我而言,在 DataTemplate 中:
<Setter Property="xct:TouchEffect.Command" Value="{Binding Source={x:Reference SamplePage}, Path=BindingContext.sampleCommand}" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.