WPF滑块层问题
我正在使用 WPF 滑块,并且基本上使用它来实现“拉出控件”。
基本上它是一个有两个位置的滑块控件:0 和 1
我在最左侧有这个控件,所以您最初看到的是拇指位置为 0。 然后,用户可以将其拖出到 1 位置以查看滑块拇指的完整视图。
我遇到一个问题,如果您注意到滑块位于另一个控件之上,由于这种情况,我们无法与底层控件进行交互。
我尝试过的:
在默认样式中,我尝试将轨道上的 HitTestVisible 属性应用为 false;以及其他可能的元素。然而,由于拇指,它会使整个控件无法进行 HitTest'able。
|*------|
0 1
有关如何以某种方式使滑块控件 HitTestVisible=false 同时使滑块拇指 HitTestVisible=true 的任何想法。
I'm using a WPF slider and have basically used it to implement a "Pull out control".
Basically it's a slider control with two positions: 0 and 1
I have this control on the far left side so what you initially see is the thumb position at 0.
The user can then drag it out to the 1 position to see the full view of the slider thumb.
I have an issue where if you notice, the slider is laying over another control and since this is the case, we are unable to interact with the underlying control.
What I've tried:
Within the default style, I've tried to apply the HitTestVisible property on the track to be false; as well as other possible elements. However since the thumb, it would make the whole control not HitTest'able.
|*------|
0 1
Any ideas on how I can somehow make the slider control HitTestVisible=false while also making the Slider thumb HitTestVisible=true.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以我发现了这个问题。
本质上,对于滑块中的所有元素,您基本上必须将背景设置为:
这不仅使其透明,还使其不可见,这意味着我可以单击它。
So I've found the issue.
Essentially for all the elements within the Slider, you basically have to set the Background to:
This not only makes it transparent, it also makes it not HitTestVisible, which means I can click through it.
如果您去掉轨道中的增加和减少按钮,并且轨道本身没有设置背景,我不确定什么会捕获您的输入(拇指除外)。您是否想在拇指本身内放置额外的控件?如果是这样,那可能不会很好,我想我会寻找另一种方法。
我可能会误解这里的细节,所以也许看看你的一些代码会有所帮助。我不太清楚滑块的哪一部分覆盖了您要使用的控件。
If you get rid of the increase and decrease buttons in the track, and you don't have a background set on the track itself, I'm not sure what would be capturing your input (other than the thumb). Are you trying to put additional controls within the thumb itself? If so, that probably wouldn't work very well and I think I'd look for another way.
I might be misunderstanding the details here, so maybe seeing some of your code would help. I'm not really clear what part of the slider is covering the controls you're trying to use.