wpf 相关问题

Windows Presentation Foundation或WPF是用于在基于Windows的应用程序中呈现用户界面的子系统。

如何使用 EF 存储/映射复杂数据类型?

CategoryModel 具有对象画笔类型(复杂数据类型)的属性和依赖属性颜色,无法直接使用 EF 存储,因此我使用序列化并将其存储为字符串。 使用系统...

回答 1 投票 0

使用 WPF 进行全局事件监控

我想在这件事上寻求帮助:在WPF中,我想监视keydown、mousedown和mousewheel事件,即使窗口当前不是活动的。我在WPF中使用c#。我尝试了很多...

回答 1 投票 0

WPF C# - 文本块输入未保存到导航到新页面?

我目前在 WPF 中的页面导航方面遇到问题,我目前有一个带有侧边栏的主窗口,以及窗口中间的一个框架来显示新页面。侧边栏导航似乎...

回答 1 投票 0

C# WPF 菜单在升级为 SDK 风格后不再起作用

问题:使用升级助手升级为SDK样式后,菜单不再起作用 初始点: 项目类型:WPF应用程序(.Net Framework) 默认生成App.xaml 修改MainWindow.xaml...

回答 1 投票 0

当我使用用户控件时,用户控件中的 WPF 图像未显示在编辑器中

在我的程序中,我有选项卡和选项卡栏用户控件来按住按钮以在它们之间切换。选项卡栏中的按钮是我制作的 TabButton 用户控件,其背面有图像...

回答 1 投票 0

将多个类绑定到 WPF 树视图

我的 Treeview 已正确绑定到 ClassModel,但我将有一些具有子 CADModel 的类模型,我无法让我的层次模板正常工作 提前致谢 马克 <

回答 1 投票 0

不支持BitmapEncoder保存

我有以下代码,我看不出有什么问题,有什么想法可能是什么问题吗? 私有静态字符串 SaveBaseImage( ZipArchive arc, DBImage image, int imageIndex ) { 使用 (...

回答 1 投票 0

如果无法通过样式设置子控件属性,如何通过 XAML 设置子控件属性

我想在用户控件中设置子控件的属性。 我想在用户控件中设置子控件的属性。 <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="auto"/> </Grid.ColumnDefinitions> <Label Grid.Column="0" x:Name="cLabel" Content="{Binding Caption}" /> <TextBox Grid.Column="1" x:Name="cTextBox" Text="{Binding Text}"/> <Label Grid.Column="2" x:Name="cUnit" Content="{Binding Unit}"/> </Grid> <!-- how to set only cLabel Width? something like: --> <local:LabeledTextbox cLabel.Width=100> 我想它不可能通过样式,因为样式也会设置cUnit。对吗? 我尝试了样式,但它设置了所有子项。 您可以使用该元素的资源来设置这些属性。 <local:LabeledTextbox> <local:LabeledTextbox.Resources> <Style TargetType="Label"> <Setter Property="Width" Value="100" /> <Setter Property="BorderBrush" Value="Gray" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="Margin" Value="4" /> <Setter Property="Foreground" Value="Purple" /> <Setter Property="FontStyle" Value="Italic" /> </Style> </local:LabeledTextbox.Resources> </local:LabeledTextbox> 或者,如果您想为多个控件设置该值,您可以将要隔离的内容块包装在某种容器控件中,并为包含元素设置资源,如下所示: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions> <Label Grid.Column="0" x:Name="cLabel" Content="Caption" /> <TextBox Grid.Column="1" x:Name="cTextBox" Text="Text" /> <Label Grid.Column="2" x:Name="cUnit" Content="Unit" /> </Grid> <StackPanel> <StackPanel.Resources> <Style TargetType="Label"> <Setter Property="Width" Value="100" /> <Setter Property="BorderBrush" Value="Gray" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="Margin" Value="4" /> <Setter Property="Foreground" Value="Purple" /> <Setter Property="FontStyle" Value="Italic" /> </Style> </StackPanel.Resources> <local:LabeledTextbox /> <local:LabeledTextbox /> <local:LabeledTextbox /> </StackPanel>

回答 1 投票 0

WPF 文件信息表

我对 C# 和 WPF 比较陌生,我是否在努力获取要显示的文件信息列表。下面是我正在使用的代码。我已经测试过该集合填充了正确的

回答 1 投票 0

如何在 WPF 中将动画设置为半透明颜色?

简化(!)示例: 简化(!)示例: <Window Background="Black"> <Button Background="#ff272727" Content="Whatever" Foreground="White" Padding="16,8" HorizontalAlignment="Center" VerticalAlignment="Center"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="container" Background="{TemplateBinding Background}"> <ContentPresenter Margin="{TemplateBinding Padding}" /> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualStateGroup.Transitions> <VisualTransition GeneratedDuration="0:0:2" /> </VisualStateGroup.Transitions> <VisualState x:Name="Normal" /> <VisualState x:Name="MouseOver"> <Storyboard> <ColorAnimation Storyboard.TargetName="container" Storyboard.TargetProperty="Background.Color" To="#33ff8000" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Border> </ControlTemplate> </Button.Template> </Button> </Window> 将鼠标悬停在按钮上时,我希望颜色在 2 秒的时间内从 #ff272727(不透明深灰色)过渡到 #33ff8000(半透明橙色)。然而,实际发生的情况是,它首先非常快速地(我估计大约四分之一秒)过渡到看起来像 #ffff8000 的样子,然后在剩下的 2 秒内继续 #33ff8000 。 从本质上讲,它似乎是一个接一个地对颜色和 alpha 分量进行动画处理,而不是同时对两者进行动画处理。 有趣的是,如果我交换两种颜色的 alpha 值,即当我从半透明颜色设置动画为完全不透明颜色时,不会发生同样的事情。似乎只有当To颜色不透明时才会发生。 对我来说另一个有趣的观察是,即使使用这个故事板也会发生完全相同的现象: <Storyboard> <DoubleAnimation Storyboard.TargetName="container" Storyboard.TargetProperty="Background.Opacity" To="0.2" /> <ColorAnimation Storyboard.TargetName="container" Storyboard.TargetProperty="Background.Color" To="#ffff8000" /> </Storyboard> 这也将首先对颜色进行动画处理,然后对不透明度进行动画处理... 我做错了什么还是这是一个已知问题?如果是这样,是否有任何已知的解决方法? 这其实是你的眼睛欺骗了你。光是一件棘手的事情,它的强度不是线性的(对数或接近平方取决于我们正在讨论的光强度/颜色的哪个方面)。此外,从灰色到橙色的步骤比减少不透明度要短得多,因此您的眼睛比不透明度变化更快地察觉到这种情况发生。 这里有几个深入探讨该主题的链接: https://computergraphics.stackexchange.com/q/1587 https://www.youtube.com/watch?v=LKnqECcg6Gw 为了用您的示例说明这种现象,我更改了您的模板以显示动画正在做什么。在下面的结果中,您可以看到它确实线性地穿过两个值。 <Button Background="#FF272700" Foreground="White" Padding="16,8" HorizontalAlignment="Center" VerticalAlignment="Center"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="container" Background="{TemplateBinding Background}" Padding="16,8"> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Text="{Binding Background.Color, ElementName=container}" /> <TextBlock Grid.Row="1" Text="{Binding Background.Opacity, ElementName=container}" /> </Grid> <!--<ContentPresenter Margin="{TemplateBinding Padding}" />--> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualStateGroup.Transitions> <VisualTransition GeneratedDuration="0:0:05" /> </VisualStateGroup.Transitions> <VisualState x:Name="Normal" /> <VisualState x:Name="MouseOver"> <Storyboard Changed="Storyboard_Changed"> <DoubleAnimation Storyboard.TargetName="container" Storyboard.TargetProperty="Background.Opacity" To="0.2" /> <ColorAnimation Storyboard.TargetName="container" Storyboard.TargetProperty="Background.Color" To="#ff8000" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Border> </ControlTemplate> </Button.Template> </Button> 解决方法是分别更改动画的速度和/或起点,让它们按照您想要的方式显示。

回答 1 投票 0

为什么 WPF ProgressBar PART_Indicator 添加不透明度?

我正在尝试为 WPF 中的 ProgressBar 控件制作自定义样式。但 PART_Indicator 正在降低栏右侧的不透明度。 (查看 25%、50%、75% 的示例) 当酒吧达到 100% 时...

回答 1 投票 0

创建 WPF 窗口作为 Win32 MDI 主机窗口的 MDI 子窗口

我有一个本机 Win32 MDI 应用程序。该应用程序调用创建 WPF 窗口的非托管代码,并调用 User32.SetParent() 将其包装到 Win32 MDI 窗口中。效果很好,但是 WPF 窗口

回答 1 投票 0

你好,我创建了 3 个 viewModel,想要将它们连接到单个视图(UI),但不能

我有 3 个 viewModel(AdminViewModel、StudentViewModel、ProfessorViewModel),我有一个 UI,用户可以在其中登录数据库,我创建了一个名为 ExtractRole 的方法,它扮演用户的角色...

回答 1 投票 0

在尝试删除之前检查文件是否仍然打开,并循环直到它空闲

我有一个 WPF 应用程序,它以 Byte() 的形式从数据库中提取 Word 文件,保存到临时目录,然后互操作处理该文件以制作另一个包含 x 页的文件 - 也保存到同一目录。终于

回答 1 投票 0

不仅仅是一个简单的自定义按钮

如何创建一个自定义按钮,其中包含根据 AsyncCommand 中的 IsExecuting 变化的图像?它需要在不创建 UserControl 的情况下实现,只能通过继承...

回答 1 投票 0

TextBlock 中的 WPF 格式日期时间?

我有一个绑定到 DateTime 属性的 TextBlock。如何配置日期的格式?

回答 4 投票 0

更换头像

Visual Studio 2022。C#。 WPF。 NET8.0 在设置过程中,我的应用程序要求提供特定尺寸的个人资料图片。如果用户添加它,它会保存在某个文件夹中作为“ProfilePic”。如果用户不添加,则

回答 1 投票 0

Wpf 子表单,OnClosing 事件和等待

我有一个从父表单启动的子表单,其中包含: ConfigForm cfg = new ConfigForm(); cfg.ShowDialog(); 该子表单用于配置一些应用程序参数。 我想检查一下是否...

回答 2 投票 0

WPF PreviewMouseRightButtonDown 与 MouseRightButtonDown 事件

当我们在处理鼠标右键事件时应该使用 PreviewMouseRightButtonDown 事件而不是 MouseRightButtonDown 事件? 请详细说明易用性。

回答 2 投票 0

从自定义 UserControl 的 DependencyProperty 返回值并使用 viewModel 的正确方法?

我将自定义用户控件包装到 dll,并希望引用它的其他人能够通过绑定到“Result”属性来获取或设置结果值。 这是 CustomControl.cs 代码: 公开部分

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.