这不起作用:
<Picker ItemsSource="{Binding myList}" Title="Select one" SelectedItem="{Binding myItem}">
<Picker.Triggers>
<EventTrigger Event="Focused">
<local:FocusedTriggerAction />
</EventTrigger>
</Picker.Triggers>
<Picker.ItemDisplayBinding>
<Binding Path="FullName"/>
</Picker.ItemDisplayBinding>
</Picker>
我不认为“聚焦”是一个可接受的选择器触发器。有没有可用的解决方法?
答案 0 :(得分:0)
使用基于触摸的输入时,下面示例中的颜色更改似乎在显示选择器列表时在模拟器中生效。
<Picker Title="Select" ItemsSource="{Binding Items}" SelectedItem="{Binding Item}">
<Picker.Triggers>
<EventTrigger Event="Focused">
<local:FocusTriggerAction TextColor="Green" />
</EventTrigger>
<EventTrigger Event="Unfocused">
<local:FocusTriggerAction TextColor="Default" />
</EventTrigger>
</Picker.Triggers>
</Picker>
public class FocusTriggerAction : TriggerAction<VisualElement>
{
public Color TextColor { get; set; }
protected override void Invoke(VisualElement visual)
{
var view = visual as Picker;
if (view == null) return;
if (TextColor != null) view.TextColor = TextColor;
Debug.WriteLine(visual.IsFocused ? "Focused" : "Unfocused");
}
}