Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 拇指控件高亮显示并拖动外观_C#_Windows Runtime - Fatal编程技术网

C# 拇指控件高亮显示并拖动外观

C# 拇指控件高亮显示并拖动外观,c#,windows-runtime,C#,Windows Runtime,我正在windows应用商店应用程序中使用thumb控件来表示可拖动的图像。然而,每当我将鼠标悬停在它上面时,它就会变成一个灰色框,当我拖动它时,它就会变成一个深灰色框。当释放时,它会恢复到我给它作为背景的图像。有没有办法关闭或自定义高光/焦点和拖动外观 编辑: 这是我的XAML控件。我把它放在一个格子里,但什么都不做 <Canvas x:Name="PART_background" Background="White" Height="140" Width="20"> &l

我正在windows应用商店应用程序中使用thumb控件来表示可拖动的图像。然而,每当我将鼠标悬停在它上面时,它就会变成一个灰色框,当我拖动它时,它就会变成一个深灰色框。当释放时,它会恢复到我给它作为背景的图像。有没有办法关闭或自定义高光/焦点和拖动外观

编辑:

这是我的XAML控件。我把它放在一个格子里,但什么都不做

<Canvas x:Name="PART_background" Background="White" Height="140" Width="20">
    <Thumb x:Name="PART_drag" Canvas.Left="0" Width="20" Height="50">
        <Thumb.BorderBrush>
            <SolidColorBrush Color="Black" Opacity="0"></SolidColorBrush>
        </Thumb.BorderBrush>

        <Thumb.Background>
            <ImageBrush x:Name="PART_image" Stretch="None" AlignmentX="Center" />
        </Thumb.Background>
    </Thumb>
</Canvas>

您需要编辑模板-它在混合中效果最好,然后更改视觉状态动画。默认模板有几个
边框
元素,对于各种视觉状态(PointerPressed、PointerOver)-它为这些边框的不透明度设置动画。这是提取的模板。您可以简单地删除故事板以消除视觉反馈

<Page
    x:Class="App132.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App132"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
        <Style x:Key="ThumbStyle1" TargetType="Thumb">
            <Setter Property="Background" Value="{StaticResource ThumbBackgroundThemeBrush}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="BorderBrush" Value="{StaticResource ThumbBorderThemeBrush}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Thumb">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="PointerOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundPointerOver"/>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Background"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundPressed"/>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Background"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Unfocused"/>
                                    <VisualState x:Name="Focused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="Background" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                            <Border x:Name="BackgroundPointerOver" BorderBrush="{StaticResource ThumbPointerOverBorderThemeBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{StaticResource ThumbPointerOverBackgroundThemeBrush}" Opacity="0"/>
                            <Border x:Name="BackgroundPressed" BorderBrush="{StaticResource ThumbPressedBorderThemeBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{StaticResource ThumbPressedBackgroundThemeBrush}" Opacity="0"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Page.Resources>

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Thumb HorizontalAlignment="Left" Height="270" Margin="170,230,0,0" VerticalAlignment="Top" Width="390" Style="{StaticResource ThumbStyle1}"/>
    </Grid>
</Page>


发布您当前的XAML。我使用此模板将样式内联到thumb控件上,效果非常好!