如何通过触摸控制使用 SurfaceSlider

发布于 2024-11-29 09:45:55 字数 2036 浏览 0 评论 0 原文

我想在标签可视化中使用 Surfaceslider 控件,以便在放置对象时它可以响应手指触摸,但是当我运行程序时它根本不移动。任何人都可以给我指点吗(我是这个sdk的新手)。


<s:TagVisualization x:Class="ControlsBox.TagVisual"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
Loaded="TagVisual_Loaded">
<Grid>
    <!--ProgressBar Margin="50" HorizontalAlignment="Center" Value=""-->
    <TextBlock Height="23" HorizontalAlignment="Center" Margin="0" Name="textBlock1" Text="" VerticalAlignment="Top" Padding="0,6,0,0" Foreground="#FFAA4A4A" />
    <s:SurfaceSlider Width="100" Height="20" HorizontalAlignment="Center" VerticalAlignment="Top" Padding="0,50,0,0" Value="60" IsSelectionRangeEnabled="False" Margin="20" Name="mySlider" Maximum="100" Interval="1" ValueChanged="mySlider_ValueChanged">
        <s:SurfaceSlider.Effect>
            <BlurEffect Radius="2"/>
        </s:SurfaceSlider.Effect>
    </s:SurfaceSlider>
    <Ellipse Width="200" Height="200" Stroke="White" StrokeThickness="8" Opacity="0.7">
        <Ellipse.Effect>
            <BlurEffect Radius="12" />
        </Ellipse.Effect>
    </Ellipse>
    <Ellipse Height="196" Width="196" Stroke="AntiqueWhite" StrokeThickness="4" >
        <Ellipse.Effect>
            <BlurEffect Radius="4"/>
        </Ellipse.Effect>   
    </Ellipse>
    <Label Content="John's Phone" HorizontalContentAlignment="Center" Padding="0,150,0,0" VerticalContentAlignment="Bottom">
        <Label.Effect>
            <DropShadowEffect BlurRadius="9" ShadowDepth="0" Color="Aqua"/>
        </Label.Effect>
    </Label>

</Grid>


    private void mySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
    {
        this.textBlock1.Text = Math.Round(this.mySlider.Value/100,2).ToString();
    }

I want to use my surfaceslider control inside tagvisualization so that it responds to finger touch when an object is placed, but when I run the program it doesnt moves at all. Can anybody give me pointers (I am new to this sdk).


<s:TagVisualization x:Class="ControlsBox.TagVisual"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
Loaded="TagVisual_Loaded">
<Grid>
    <!--ProgressBar Margin="50" HorizontalAlignment="Center" Value=""-->
    <TextBlock Height="23" HorizontalAlignment="Center" Margin="0" Name="textBlock1" Text="" VerticalAlignment="Top" Padding="0,6,0,0" Foreground="#FFAA4A4A" />
    <s:SurfaceSlider Width="100" Height="20" HorizontalAlignment="Center" VerticalAlignment="Top" Padding="0,50,0,0" Value="60" IsSelectionRangeEnabled="False" Margin="20" Name="mySlider" Maximum="100" Interval="1" ValueChanged="mySlider_ValueChanged">
        <s:SurfaceSlider.Effect>
            <BlurEffect Radius="2"/>
        </s:SurfaceSlider.Effect>
    </s:SurfaceSlider>
    <Ellipse Width="200" Height="200" Stroke="White" StrokeThickness="8" Opacity="0.7">
        <Ellipse.Effect>
            <BlurEffect Radius="12" />
        </Ellipse.Effect>
    </Ellipse>
    <Ellipse Height="196" Width="196" Stroke="AntiqueWhite" StrokeThickness="4" >
        <Ellipse.Effect>
            <BlurEffect Radius="4"/>
        </Ellipse.Effect>   
    </Ellipse>
    <Label Content="John's Phone" HorizontalContentAlignment="Center" Padding="0,150,0,0" VerticalContentAlignment="Bottom">
        <Label.Effect>
            <DropShadowEffect BlurRadius="9" ShadowDepth="0" Color="Aqua"/>
        </Label.Effect>
    </Label>

</Grid>


    private void mySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
    {
        this.textBlock1.Text = Math.Round(this.mySlider.Value/100,2).ToString();
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾其所爱 2024-12-06 09:45:55

标签将其覆盖,因此触摸不会触及它。在标签和其他任何您不希望接收触摸输入的内容上设置 IsHitTestVisible=false。鼠标输入的工作方式相同。像“Snoop”这样的工具非常适合调试此类问题

The label is covering it up so the touch doesn't get to it. Set IsHitTestVisible=false on the label and anything else you don't want to receive touch input. Mouse input works the same way. Tools like "Snoop" are great for debugging issues like this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文