Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.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#_Wpf - Fatal编程技术网

C# 为什么工具提示延迟不能按预期工作?

C# 为什么工具提示延迟不能按预期工作?,c#,wpf,C#,Wpf,我的按钮有一个工具提示实现 <Button Grid.Row="0" ToolTip="{x:Static res:Resources.tooltip_add_clip_s_for_processing}" x:Name="Btn_path_to_clip_folder" Cl

我的
按钮有一个
工具提示
实现

<Button Grid.Row="0"
                                    ToolTip="{x:Static res:Resources.tooltip_add_clip_s_for_processing}"
                                    x:Name="Btn_path_to_clip_folder"
                                    Click="Btn_path_to_clip_folder_Click"
                                    Content="{x:Static res:Resources.add_dots}"
                                    Cursor="Hand"
                                    Margin="4"
                                    HorizontalAlignment="Stretch"/>
然后我在我的
UserControl

<UserControl x:Class="MMy_proj.UserControls.UCClipProcessing"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:converters="clr-namespace:My_proj.Converters"
             xmlns:res="clr-namespace:My_proj.Properties"
             xmlns:vm="clr-namespace:My_proj.Model.Binding;assembly=My_proj"
             Background="WhiteSmoke"
             mc:Ignorable="d" 
             ToolTipService.InitialShowDelay="2000"           <--- !!! This line
             d:DesignHeight="800" d:DesignWidth="1000">
...
</>

我不确定来自另一个线程的解决方案应该如何工作。在我的测试中没有任何改变

唯一对我有用的是:

public MainWindow()
        {
            InitializeComponent();

            ToolTipService.InitialShowDelayProperty
                .OverrideMetadata(typeof(FrameworkElement),
                    new FrameworkPropertyMetadata(2000));
        }
明显的缺点:延迟不是在XMAL中配置的,而是在代码隐藏中配置的

public MainWindow()
        {
            InitializeComponent();

            ToolTipService.InitialShowDelayProperty
                .OverrideMetadata(typeof(FrameworkElement),
                    new FrameworkPropertyMetadata(2000));
        }