dependency-properties 相关问题

WPF和Silverlight中支持数据绑定的属性,包括样式,继承,动画和默认值。它允许您在DependencyObject上设置附加属性。

为什么 Ellipse 的 Fill 的 ImageSource 属性不接受 ImageSource 对象类型?

我有一个名为“Image”的 ImageSource 类型的 DependencyProperty。 公共静态只读 DependencyProperty ImageProperty = DependencyProperty.Register(nameof(Image), typeof(ImageSource), ty...

回答 1 投票 0

WPF ICommand DependencyProperty 显示“绑定”只能在设计器中的 DependencyObject 的 DependencyProperty 上设置[重复]

我有一个自定义按钮控件,其 ICommand 属性配置为依赖项属性,如下所示: 公共部分类 SpecialButton : UserControl { 公共静态只读 DependencyPro...

回答 1 投票 0

WPF 自定义用户控件 - 数据绑定不更新 DataContext 的属性

我正在封装一个我编写的快速脏水印文本框,以便我可以在我的应用程序中重用它:BetterTextBox。除了使用新的更新底层 DataContext 之外,一切都在其中工作......

回答 1 投票 0

只读 XAML 属性

我有一个名为 GridContainer 的 UserControl,并在 XAML 中声明了一个 DataGrid 控件。我希望在窗口中使用时能够从 XAML 访问此 DataGrid: ...

回答 1 投票 0

Avalonia 的 TilePanel,`DependencyProperty` 到 `AvaloniaProperty`

我想要一个 Avalonia 的 WrapPanel,它通过将项目彼此相邻放置而包装其内容,没有间距,就像本文中一样:https://www.codeproject.com/Articles/482501/TilePanel-An-

回答 1 投票 0

使用 pip 安装了错误的依赖项

我想知道是否有人可以帮助我解决这个问题: 我有两个 python 库 Lime 和 Specsy,其中第一个库是第二个库的依赖项。 当我向 PyPi 添加石灰时...

回答 1 投票 0

在UWP App中,使用DependencyProperty,TextBlock的FontSize和FontStyle发生了变化,但FontFamily没有发生变化

使用 UWP 我想打印包含 TextBlock 的报告。根据偏好,我想更改 TextBlock FontSize、FontStyle 和 FontFamily,但 DependencyProperty 会更改 FontSize 和

回答 1 投票 0

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

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

回答 1 投票 0

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

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

回答 1 投票 0

将属性值从父级用户控件传递到子级的 DependencyProperty

如何将属性(SomeProperty)从ParentUserControl上下文传递到ChildUserControl的DependencyProperty(MyDProperty)? 在 XAML 中,它应该是: 如何将 ParentUserControl 上下文中的 property (SomeProperty) 传递到 ChildUserControl 的 DependencyProperty (MyDProperty)? 在XAML中,应该是: 但是,由于某种原因,MyDProperty 永远不会使用 Parent.DataContext.SomeProperty 设置。 就我而言,我正在传递一个操作,但这并不重要。我认为问题出在绑定上。 家长用户控制: public Action RemoveEsl1 => throw new NotImplementedException(); <uc:ChildUserControl Title="ESL 1" RemoveEslAction="{Binding RemoveEsl1}" DataContext="{Binding Esl1}"/> 子用户控件: public static readonly DependencyProperty RemoveEslActionProperty = DependencyProperty.Register(nameof(RemoveEslAction), typeof(Action), typeof(ChildUserControl), new PropertyMetadata(delegate { })); public Action RemoveEslAction { get => (Action)GetValue(RemoveEslActionProperty); set => SetValue(RemoveEslActionProperty, value); } 我在这里找到了各种技巧,但没有一个适合我或有效。 回答我自己的问题(检查 ParentUserControl): 型号: public class RootModel : ViewModelBase { private ParentModel parentModel = new(); public ParentModel ParentModel { get => parentModel; set => RisePropertyChanged(ref parentModel, value); } } public class ParentModel : ViewModelBase { private ChildModel childModel = new(); public ChildModel ChildModel { get => childModel; set => RisePropertyChanged(ref childModel, value); } public string ParentModelProperty => "Correct value from ParentModel"; } public class ChildModel : ViewModelBase { private string childModelProperty = "Wrong default value from ChildModel"; public string ChildModelProperty { get => childModelProperty; set => RisePropertyChanged(ref childModelProperty, value); } } 主窗口: <Window.DataContext> <model:RootModel/> </Window.DataContext> <uc:ParentUserControl DataContext="{Binding ParentModel}"/> 家长用户控件: <uc:ChildUserControl ChildDependency="{Binding DataContext.ParentModelProperty, RelativeSource={RelativeSource AncestorType=UserControl}}" DataContext="{Binding ChildModel}"/> 子用户控件: <StackPanel> <Label Content="Dependency property:"/> <Label Content="{Binding ChildDependency, RelativeSource={RelativeSource AncestorType=UserControl}}"/> <Separator/> <Label Content="Property:"/> <Label Content="{Binding ChildModelProperty}"/> </StackPanel> public partial class ChildUserControl : UserControl { public static readonly DependencyProperty ChildDependencyProperty = DependencyProperty.Register(nameof(ChildDependency), typeof(string), typeof(ChildUserControl), new ("Wrong default DP value from ChildUserControl")); public string ChildDependency { get => (string)GetValue(ChildDependencyProperty); set => SetValue(ChildDependencyProperty, value); } public ChildUserControl() { InitializeComponent(); } } 这就是如何将属性 (SomeProperty) 从 ParentUserControl 上下文传递到 ChildUserControl 的 DependencyProperty (MyDProperty)。

回答 1 投票 0

WPF UserControl 无法与 DependencyProperty OnSomeBytePropertyChanged 一起使用

首先,我在 WPF 项目中创建了一个 UserControl,用于在设置窗口中设置颜色。 该窗口有一个名为 MainWindowViewModel.cs 的 ViewModel,其中包含: 使用 System.Collections.ObjectMo...

回答 1 投票 0

WPF 将页面分配给依赖属性

TL;DR:将 {StaticResource SomePage} 绑定到 Page 类型的 DependencyProperty 会出现错误 Microsoft.VisualStudio.XSurface.Wpf.Page 不是属性的有效值... 长版 我正在尝试...

回答 1 投票 0

如何将自定义 UserControl 的依赖属性双向绑定到另一个 UserControl 的 DataContext 的属性?

我有一个用户控件,其代码隐藏已声明依赖属性。我还有另一个 UserControl 作为主 UI。 主 UI 用户控件已将其 DataContext 设置为 viewmo...

回答 1 投票 0

有没有办法可以使用这个依赖属性? WPF C#

我试图在自定义控件中设置 SKQuantitySpinEdit 父类的增量属性,但无法这样做! ControlTemplate spinOptLegQuantityTemplate = (ControlTemplate)(grdMultiF...

回答 1 投票 0

MVVM、XAML、C# - DependencyProperty - ItemsControl 中的 ObservableCollection 无法识别 Property

我对 MVVM 和 c# 系统相当陌生,只是将其用作一个小小的业余爱好。在过去的三天里,我一直对以下问题感到绝望。 我有一个带有相应的自定义控件视图...

回答 2 投票 0

无法实例化[org.flywaydb.core.Flyway]:工厂方法“flyway”抛出异常并显示消息:名称不能为空

spring从2.7.x升级到3.2.1版本后 并将 Flyway 从 8.5 升级到版本 10.4.1 时,我收到了如标题所示的异常: 无法实例化 [org.flywaydb.core.Flyway]:工厂

回答 1 投票 0

WPF 绑定到 UserControl 的 DependencyProperty 未按预期工作[重复]

我在 DependecyProperty 绑定方面遇到一些奇怪的问题。 为了使问题更简单,我创建了一些虚拟控件,它具有相同的不需要的行为 我有一个用户控件,它有一个

回答 1 投票 0

WPF 绑定到自定义控件依赖属性不会触发属性更改

我在绑定到自定义控件上的依赖属性时遇到问题。 这是我的自定义控件。它基本上是一个文本框,只允许数字输入并公开“值”依赖项

回答 1 投票 0

ObservableCollection 绑定到另一个 ObservableCollection 不会触发 CollectionChanged

我有 ControlA 托管 ControlB,它们都有 ObservableCollection 类型的 DependencyProperty,嵌套控件的 (ControlB) 属性绑定到父级 (ControlA) 属性,如果有的话

回答 1 投票 0

如何为自定义WPF控件添加最小和最大验证?

我想创建一个具有多个 WPF 依赖属性的自定义控件。 属性之一是返回 Thickness 对象。 自定义控件应该适合设计使用...

回答 1 投票 0

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