问题标签 [attached-properties]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
silverlight - 绑定到 ControlTemplate 中的附加属性 - Silverlight
我有这种风格:
问题是绑定不适用于按钮:
我做错了什么?
wpf - 我的数据触发器绑定有什么问题?
我创建了一个附加属性来扩展具有附加状态的 Button 类:
ControlTemplate
然后我想像这样访问这个值DataTrigger
:
但我得到这个错误:
System.Windows.Data 错误:4:找不到与引用'RelativeSource FindAncestor,AncestorType='System.Windows.Controls.Button',AncestorLevel='1''的绑定源。绑定表达式:路径=(0);数据项=空;目标元素是 'Button' (Name=''); 目标属性是“NoTarget”(类型“对象”)
中的绑定表达式DataTrigger
似乎不正确。我究竟做错了什么?
wpf - XAML:在类型 VisualStateManager 中找不到可附加属性 VisualStateGroups
我正在使用 VS2008 EE SP1 + WPF + XAML。一开始我添加了对它的引用:
编译时出现此错误:
有人知道原因和可能的解决方法吗?
wpf - 将元素焦点与附加属性绑定?
我正在尝试将我的控件的焦点绑定到视图模型上的属性,如下所示:
这适用于第一个焦点,但之后它似乎根本没有任何影响
任何人都知道我做错了什么,甚至是更好的方法来做我想要实现的目标?
wpf - 附加的依赖对象被销毁\断开连接时的垃圾收集
当我们对任何依赖对象使用任何附加属性时,我认为它实际上将属性和值映射到依赖对象。
例如<DockPanel><TextBlock x:Name="MyText" DockPanel.Dock="Top"/></DockPanel>
这里值“Top”通过依赖对象文本块“MyText”映射到 DockPanels DockProperty
但我的问题是这个映射什么时候处理?我问这个的原因是 DockPanel 的 DockProperty 是静态\共享的。所以它必须有这样的多个映射对(值,依赖对象)在某种内部字典中对其进行维护。(只是猜测)
所以这必须在依赖对象被销毁时进行垃圾回收。
所以现在我的观点是有什么方法可以让我知道是否发生了这样的附加属性处置(比如给定附加属性和依赖对象的某种解除或处置事件)?
此外,如果这种垃圾收集没有发生,那么这不是内存泄漏吗?
谢谢Vinit Sankhe。
wpf - WPF - 随机挂起文件浏览器附加行为
我有一个这样定义的附加行为,..
这是一个很好的简单附加行为,当您单击文本框时会弹出打开 OpenFileDialog 并在完成后将文件名放入框中。
它可能在 40% 的时间内工作,但其余时间整个应用程序都会挂起。此时的调用堆栈如下所示 -
WindowsBase.dll!MS.Win32.UnsafeNativeMethods.GetMessageW(ref System.Windows.Interop.MSG msg, System.Runtime.InteropServices.HandleRef hWnd, int uMsgFilterMin, int uMsgFilterMax) + 0x15 bytes
WindowsBase.dll!System.Windows.Threading。 Dispatcher.GetMessage(参考 System.Windows.Interop.MSG msg,System.IntPtr hwnd,int minMessage,int maxMessage)+ 0x48 字节 WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame 帧= {System.Windows.Threading.DispatcherFrame}) + 0x8b 字节 WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame 帧) + 0x49 字节
WindowsBase.dll!System.Windows.Threading。 Dispatcher.Run() + 0x4c 字节
PresentationFramework.dll!System.Windows.Application.RunDispatcher(对象忽略) + 0x1e 字节
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window 窗口) + 0x6f 字节 PresentationFramework.dll!System.Windows.Application。 Run(System.Windows.Window window) + 0x26 bytes PresentationFramework.dll!System.Windows.Application.Run() + 0x19 bytes Debugatron.exe!Debugatron.App.Main() + 0x5e bytes C# [Native to Managed Transition]
[管理到本地转换]
mscorlib.dll!System.AppDomain.nExecuteAssembly(System.Reflection.Assembly 程序集,string[] args) + 0x19 字节 mscorlib.dll!System.Runtime.Hosting.ManifestRunner.Run(bool checkAptModel) + 0x6e 字节 mscorlib.dll!System .Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() + 0x84 字节 mscorlib.dll!System.Runtime.Hosting.ApplicationActivator.CreateInstance(System.ActivationContext activationContext, string[] activationCustomData) + 0x65 字节 mscorlib.dll!System.Runtime.Hosting。 ApplicationActivator.CreateInstance(System.ActivationContext activationContext) + 0xa 字节 mscorlib.dll!System.Activator.CreateInstance(System.ActivationContext activationContext) + 0x3e 字节
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() + 0x23 字节
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(对象状态) + 0x66 字节
mscorlib.dll!System.Threading。 ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback 回调, 对象状态) + 0x6f 字节
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 字节
现在,我以前在做一些异步事情时见过这种事情,但那时还没有发生。唯一活着的线程是 UI 线程!此外,当它挂起时,我总是得到最后一个调试语句。
谁能指出我正确的方向?这个快把我逼疯了!
c# - 附加属性:设置默认值时的“System.TypeInitializationException”
我想设置我的附加属性的默认值,但是当我这样做时:
WindowsBase.dll 中出现了“System.ArgumentException”类型的第一次机会异常
在 Oef_AttDepProp.exe 中发生了“System.TypeInitializationException”类型的第一次机会异常
没有默认值,一切正常。这是我使用的一些示例代码:
似乎是“new clsPersoon("test", "test")" 导致问题的原因,但这只是一个非常简单的类,它有一个 2-string-constructor。
编辑:当尝试通过单击事件而不是 window_load 设置属性时,我得到一个 innerException:“'Eigenaar' 属性的默认值不能绑定到特定线程。”
wpf - 创建 Window.Title 附加属性
我有一个 Window shell,它基本上是:
在运行时注入 ContentPresenter 的是 UserControls。我想要做的是写:
以便使用该UserControl
Window.Title
属性更新 Window 标题。
我觉得这可以使用附加属性来实现。任何人都可以让我朝着正确的方向开始吗?
丹尼尔
c# - 如何处理 WPF 中的 Canvas.Top 更改事件?
我有一个元素定位在Canvas
使用附加属性Canvas.Top
和Canvas.Left
. 然后使用动画将元素移动到不同的坐标集,如下所示:
有没有办法在任何时候Canvas.Top
或Canvas.Left
更改时接收事件?最好与动画无关。