Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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
将自定义标签放置在滑块wpf下_Wpf_Xaml_Wpf Style - Fatal编程技术网

将自定义标签放置在滑块wpf下

将自定义标签放置在滑块wpf下,wpf,xaml,wpf-style,Wpf,Xaml,Wpf Style,我的问题是直截了当的,我想在滑块控件下面有一些标签。我在网上找到了一些有趣的解决方案,尤其是这个 要求编辑拇指,但当我使用在数据下面有这么多涂鸦的样式时,我无法让它工作 我也一直在尝试在混合中使用模板。我可以在滑块中更改刻度的颜色,但当我将textblock与一些文本一起放置时,我的期望是它会根据刻度的数量重复标签,但我看到一个textblock 任何人都可以帮助我的风格张贴在链接中,甚至编辑我的风格。这是我到目前为止的代码 <ControlTemplate x:K

我的问题是直截了当的,我想在滑块控件下面有一些标签。我在网上找到了一些有趣的解决方案,尤其是这个 要求编辑拇指,但当我使用在数据下面有这么多涂鸦的样式时,我无法让它工作

我也一直在尝试在混合中使用模板。我可以在滑块中更改刻度的颜色,但当我将textblock与一些文本一起放置时,我的期望是它会根据刻度的数量重复标签,但我看到一个textblock

任何人都可以帮助我的风格张贴在链接中,甚至编辑我的风格。这是我到目前为止的代码

<ControlTemplate
            x:Key="SliderHorizontal"
            TargetType="{x:Type Slider}">
            <Border
                x:Name="border"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                Background="{TemplateBinding Background}"
                SnapsToDevicePixels="True">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition
                            Height="Auto" />
                        <RowDefinition
                            Height="Auto"
                            MinHeight="{TemplateBinding MinHeight}" />
                        <RowDefinition
                            Height="Auto" />
                        <RowDefinition
                            Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>
                    <TickBar
                        x:Name="TopTick"
                        Fill="{TemplateBinding Foreground}"
                        Height="4"
                        Margin="0,0,0,2"
                        Placement="Top"
                        Grid.Row="0"
                        Visibility="Collapsed" />
                    <TickBar
                        x:Name="BottomTick"
                        Fill="{TemplateBinding Foreground}"
                        Height="4"
                        Margin="0,2,0,0"
                        Placement="Bottom"
                        Grid.Row="2"
                        Visibility="Collapsed" />
                    <TextBlock
                        x:Name="tblSomething"
                        Text="Hello"
                        Grid.Row="3" Foreground="Black"
                        ></TextBlock>
                    <Border
                        x:Name="TrackBackground"
                        BorderBrush="{StaticResource SliderThumb.Track.Border}"
                        BorderThickness="1"
                        Background="{StaticResource SliderThumb.Track.Background}"
                        Height="4.0"
                        Margin="5,0"
                        Grid.Row="1"
                        VerticalAlignment="center">
                        <Canvas
                            Margin="-6,-1">
                            <Rectangle
                                x:Name="PART_SelectionRange"
                                Fill="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
                                Height="4.0"
                                Visibility="Hidden" />
                        </Canvas>
                    </Border>
                    <Track
                        x:Name="PART_Track"
                        Grid.Row="1">
                        <Track.DecreaseRepeatButton>
                            <RepeatButton
                                Command="{x:Static Slider.DecreaseLarge}"
                                Style="{StaticResource RepeatButtonTransparent}" />
                        </Track.DecreaseRepeatButton>
                        <Track.IncreaseRepeatButton>
                            <RepeatButton
                                Command="{x:Static Slider.IncreaseLarge}"
                                Style="{StaticResource RepeatButtonTransparent}" />
                        </Track.IncreaseRepeatButton>
                        <Track.Thumb>
                            <Thumb
                                x:Name="Thumb"
                                Focusable="False"
                                Height="18"
                                OverridesDefaultStyle="True"
                                Template="{StaticResource SliderThumbHorizontalDefault}"
                                VerticalAlignment="Center"
                                Width="11" />
                        </Track.Thumb>
                    </Track>
                </Grid>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger
                    Property="TickPlacement"
                    Value="TopLeft">
                    <Setter
                        Property="Visibility"
                        TargetName="TopTick"
                        Value="Visible" />
                    <Setter
                        Property="Template"
                        TargetName="Thumb"
                        Value="{StaticResource SliderThumbHorizontalTop}" />
                    <Setter
                        Property="Margin"
                        TargetName="TrackBackground"
                        Value="5,2,5,0" />
                </Trigger>
                <Trigger
                    Property="TickPlacement"
                    Value="BottomRight">
                    <Setter
                        Property="Visibility"
                        TargetName="BottomTick"
                        Value="Visible" />
                    <Setter
                        Property="Fill"
                        TargetName="BottomTick"
                        Value="Orange" />
                    <Setter
                        Property="Template"
                        TargetName="Thumb"
                        Value="{StaticResource SliderThumbHorizontalBottom}" />
                    <Setter
                        Property="Margin"
                        TargetName="TrackBackground"
                        Value="5,0,5,2" />
                </Trigger>
                <Trigger
                    Property="TickPlacement"
                    Value="Both">
                    <Setter
                        Property="Visibility"
                        TargetName="TopTick"
                        Value="Visible" />
                    <Setter
                        Property="Visibility"
                        TargetName="BottomTick"
                        Value="Visible" />
                </Trigger>
                <Trigger
                    Property="IsSelectionRangeEnabled"
                    Value="true">
                    <Setter
                        Property="Visibility"
                        TargetName="PART_SelectionRange"
                        Value="Visible" />
                </Trigger>
                <Trigger
                    Property="IsKeyboardFocused"
                    Value="true">
                    <Setter
                        Property="Foreground"
                        TargetName="Thumb"
                        Value="Blue" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>