如何解决在我的触摸屏笔记本电脑中,“我的自定义滑块”不能在UWP应用程序中工作,但滑块可以正常工作吗?
using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace APO.UIElements
{
class CustomAutomationPeerSlider : Slider
{
public string GEQBarHeaderName
{ get; set; }
protected override AutomationPeer OnCreateAutomationPeer()
{
this.GotFocus += OnGEQBarFocus;
this.LostFocus += OnGEQBarFocus;
return new SliderPeer(this);
}
private void OnGEQBarFocus(object sender,Windows.UI.Xaml.RoutedEventArgs e)
{
this.GEQBarHeaderName = "";
}
private class SliderPeer : RangeBaseAutomationPeer
{
public SliderPeer(RangeBase owner)
: base(owner)
{
}
#region AutomationPeer Overrides
protected override string GetClassNameCore()
{
return "Slider";
}
protected override string GetLocalizedControlTypeCore()
{
return db;
}
protected override string GetNameCore()
{
//My logic on what it should call
return "value of slider in number not in percentage";
}
protected override bool IsControlElementCore()
{
return true;
}
protected override AutomationControlType
GetAutomationControlTypeCore()
{
return AutomationControlType.Custom;
}
protected override IList<AutomationPeer> GetChildrenCore()
{
return null;
}
#endregion
}
}
}
}
**上面的代码就像我有CustomAutomationPeerSlider滑块,正在扩展滑块** **现在,由于我尚未在此处添加所有其他功能,主要问题是当我启动窗口的讲述人并尝试滑动/触摸滑块时它没有响应,但正常的滑块工作正常。 为什么?? **
{
<localUIElement:CustomAutomationPeerSlider x:Name="Band_2"
Minimum="-10"
Maximum="10"
Margin="10,0"
utilities:StringResourceLoader.SliderHeaderResourceKey="xper_geq_band_03"
Orientation="Vertical"
Grid.Row="1"
Grid.Column="4"
ValueChanged="Band_ValueChanged"
Value="{x:Bind viewModel.GEQBands[2].Value,Mode=OneWay,Converter={StaticResource GEQBandValueConverter}}"
IsEnabled="{Binding IsOn,ElementName=GEQToggle}"
Style="{StaticResource SliderStyle}" Tag="{x:Bind viewModel.GEQBands[2].Value,Converter={StaticResource GEQBandValueConverter}}"
AutomationProperties.Name="{x:Bind Converter={StaticResource AutomationPropertyNameConverter},ConverterParameter='xper_geq_band_03'}"/>
}
更多说明: {
protected override AutomationPeer OnCreateAutomationPeer()
{
return new SliderPeer(this);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。