Как я могу получить такое направление тени, глубину тени, цвет, показанный во всплывающей подсказке (щелкните меня) на этом изображении в WPF? - PullRequest
0 голосов
/ 07 августа 2020

Я просто хочу знать глубину тени Drop Shadow, направление, радиус размытия, непрозрачность всплывающей подсказки? И что такое шестнадцатеричный цветовой код windows 10 подсказки

введите описание изображения здесь

1 Ответ

0 голосов
/ 10 августа 2020

Вы можете получить / установить значения в ControlTemplate всплывающей подсказки. В моем коде я устанавливаю имя для DropShadowEffect и получаю значение с помощью ElementName, а затем показываю значения в Grid, который включен в родительскую сетку.

<Window.Resources>
    <Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="HasDropShadow" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolTip}">
                    <Grid x:Name="grid" Background="White" >
                        <Border x:Name="Border" Margin="0,0,0,0" BorderThickness="0.5" Width="{TemplateBinding Width}" Height="150">
                            <Border.BorderBrush>
                                <SolidColorBrush Color="Gray" />
                            </Border.BorderBrush>
                            <Border.Effect>
                                <DropShadowEffect x:Name="Myeffect" ShadowDepth="6" Direction="135" Color="Maroon" Opacity="0.35" BlurRadius="0.0"/>
                            </Border.Effect>
                            <ContentPresenter Margin="4,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
                        </Border>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100"></ColumnDefinition>
                                <ColumnDefinition Width="60"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Row="0" Grid.Column="0">ShadowDepth:</TextBlock>
                            <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding ElementName=Myeffect,Path=ShadowDepth}"><!--Useful information goes here.--></TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="0">Direction:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding ElementName=Myeffect,Path=Direction}"><!--Useful information goes here.--></TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="0">Color:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding ElementName=Myeffect,Path=Color}"><!--Useful information goes here.--></TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="0">Opacity:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding ElementName=Myeffect,Path=Opacity}"><!--Useful information goes here.--></TextBlock>
                            <TextBlock Grid.Row="4" Grid.Column="0">BlurRadius:</TextBlock>
                            <TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding ElementName=Myeffect,Path=BlurRadius}"><!--Useful information goes here.--></TextBlock>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" Value="True" >
                            <Setter TargetName="Border" Property="CornerRadius" Value="0" />
                            <Setter TargetName="Border" Property="SnapsToDevicePixels" Value="true" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid>
    <Button Width="200" Height="50" HorizontalAlignment="Center" Content="Click Here">
        <Button.Template >
            <ControlTemplate TargetType="{x:Type Button}" >
                <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="7,7,7,7">
                    <Border.Background>#FFDDDDDD</Border.Background>
                    <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
                </Border>
            </ControlTemplate>
        </Button.Template>
        <Button.ToolTip>
            <ToolTip>
            </ToolTip>
        </Button.ToolTip>
    </Button>
</Grid>

Результат такой, как показано ниже: введите описание изображения здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...