C# 如何在WPF C中设置鼠标悬停在进度条上
我正在我的项目中使用甘特图的进度条,进展顺利。现在我需要显示的时间和细节时,鼠标放置在它没有点击。以前有人做过类似的事情吗?这是工具提示: 只要写下:C# 如何在WPF C中设置鼠标悬停在进度条上,c#,wpf,visual-studio,C#,Wpf,Visual Studio,我正在我的项目中使用甘特图的进度条,进展顺利。现在我需要显示的时间和细节时,鼠标放置在它没有点击。以前有人做过类似的事情吗?这是工具提示: 只要写下: <ProgressBar Minimum="0" Maximum="100" Value="75" Tooltip="Your desired text" /> 您可以为工具提示设置StackPanel,以便在鼠标悬停时显示时间和详细信息。默认情况下,当
<ProgressBar Minimum="0" Maximum="100" Value="75" Tooltip="Your desired text" />
您可以为工具提示设置StackPanel,以便在鼠标悬停时显示时间和详细信息。默认情况下,当鼠标悬停在控件上时,工具提示将弹出,下面是带有工具提示的my processbar:
<ProgressBar x:Name="MyBar" Width="200" Height="20" Value="60">
<ProgressBar.ToolTip>
<ToolTip>
<StackPanel>
<TextBox Text="Here is the details" Background="LightBlue" Height="50" Width="120"></TextBox>
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Now}}" Background="Azure" Height="50" Width="120"/>
</StackPanel>
</ToolTip>
</ProgressBar.ToolTip>
</ProgressBar>
结果图片如下所示:
我想你是说“工具提示”而不是鼠标悬停!如果您的信息是固定的,只需将它们写入“Tooltip”属性的值中,如果不是,您可以从后端绑定内容。我想我需要两者都要自定义鼠标悬停,您需要为progressbar定义样式。如果你不能解决它,让我知道,这样我可以为你写答案。我不能,请解决如果你可以。作为一个初学者,请给我描述一下,这对我很有帮助
<ProgressBar Minimum="0" Maximum="100" Value="75">
<ProgressBar .Style>
<Style TargetType="ProgressBar">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
--your desired code--
</Trigger>
</Style.Triggers>
</Style>
</ProgressBar.Style>
</ProgressBar>
<ProgressBar x:Name="MyBar" Width="200" Height="20" Value="60">
<ProgressBar.ToolTip>
<ToolTip>
<StackPanel>
<TextBox Text="Here is the details" Background="LightBlue" Height="50" Width="120"></TextBox>
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Now}}" Background="Azure" Height="50" Width="120"/>
</StackPanel>
</ToolTip>
</ProgressBar.ToolTip>
</ProgressBar>