attached-properties

How to defeat a bug with Grid.Row / Column in ItemsPanelTemplate?

一曲冷凌霜 提交于 2021-02-11 15:47:50
问题 Created a simple Attached property to simplify bindings from an element template. Instead of this: <ItemsControl ItemsSource="{Binding Mode=OneWay, Source={StaticResource Points.Grid}}" ItemsPanel="{StaticResource Grid.Panel}"> <ItemsControl.ItemTemplate> <DataTemplate DataType="Point"> <Ellipse Fill="Coral"/> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemContainerStyle> <Style> <Setter Property="Grid.Row" Value="{Binding Y}"/> <Setter Property="Grid.Column" Value="{Binding X

How to defeat a bug with Grid.Row / Column in ItemsPanelTemplate?

半世苍凉 提交于 2021-02-11 15:47:29
问题 Created a simple Attached property to simplify bindings from an element template. Instead of this: <ItemsControl ItemsSource="{Binding Mode=OneWay, Source={StaticResource Points.Grid}}" ItemsPanel="{StaticResource Grid.Panel}"> <ItemsControl.ItemTemplate> <DataTemplate DataType="Point"> <Ellipse Fill="Coral"/> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemContainerStyle> <Style> <Setter Property="Grid.Row" Value="{Binding Y}"/> <Setter Property="Grid.Column" Value="{Binding X

Get and set WPF custom attached property from code behind

旧街凉风 提交于 2020-06-12 06:19:42
问题 I generate objects of framework Rectangle class (which is sealed) and programmatically add them to Canvas. I want to add some information to that objects. Is there such a possibility? I can get and set attached properties in XAML but these is not useful for me. 回答1: You can set attached properties in code, something like this: OwningClass.SetMyAttachedProperty(textBox, true); 来源: https://stackoverflow.com/questions/35438746/get-and-set-wpf-custom-attached-property-from-code-behind

What are the various uses of Attached Properties?

强颜欢笑 提交于 2020-01-13 13:10:07
问题 I've seen some really varying uses of AttachedProperties so far in my adventures in WPF, and am wondering, what are some of the various uses? I've seen fairly mundane uses, such as those found in Grid and Canvas, as well as some really cool hacks allowing binding to collections without setters. What other applications have you found for AttachedProperties? (Code samples really helpful!) 回答1: Take a look into attached behaviours. http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx //not

What are the various uses of Attached Properties?

最后都变了- 提交于 2020-01-13 13:09:12
问题 I've seen some really varying uses of AttachedProperties so far in my adventures in WPF, and am wondering, what are some of the various uses? I've seen fairly mundane uses, such as those found in Grid and Canvas, as well as some really cool hacks allowing binding to collections without setters. What other applications have you found for AttachedProperties? (Code samples really helpful!) 回答1: Take a look into attached behaviours. http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx //not

“AttachedProperty” PropertyChangedCallback never calls for my LayoutAnchorable, but works on DockingManager. AvalonDock

蹲街弑〆低调 提交于 2020-01-07 06:15:35
问题 I am trying to use AttachedProperty in my AvalonDock, I want it to be part of LayoutAnchorable but PropertyChangedCallback never get called. i have binded AttachedPropert and i am getting the control over ViewModel ie: when binded property changes it trigger my ViewModel Property. My AttachedProperty public static readonly DependencyProperty IsCanVisibleProperty = DependencyProperty.RegisterAttached("IsCanVisible", typeof(bool), typeof(AvalonDockBehaviour), new FrameworkPropertyMetadata(new

Attached method with parameters

耗尽温柔 提交于 2020-01-06 21:52:42
问题 If you know what attached property is, then imagine a case where you need to supply 2 or more of them altogether (here is an example) and only if all of them are set something will happens. This sounds like calling a method with parameters to me, therefore a tittle. Does anyone tried anything like this? I'd imagine it can also solve my current issue with such ugly looking workaround (having 10x times of 3 property): <TextBox local:DynamicBinding.Property1="{Binding IsCheckedPath}" local

How to set Panel.ZIndex or other attached properties via DataTrigger?

↘锁芯ラ 提交于 2020-01-02 15:26:09
问题 I am trying to have a circular overlay come to the top when a certain view model enters an offline state. So it becomes partially transparent and on top of other elements in the Grid. DataTriggers in the style have worked for everything so far, but I cannot set Panel.ZIndex. There is no error in build or run, but the property is not set (I assume because it's an attached property?) <Ellipse Fill="DarkGray" Panel.ZIndex="-10" Width="50" Height="50"> <Ellipse.Style TargetType="Ellipse"> <Style>

Binding an attached property to an item in ItemsControl with custom panel problem

本秂侑毒 提交于 2020-01-02 06:23:10
问题 I can't get the following XAML to work as I want. All bindings work because get no errors from the bindings. But I don't get the expected result from the binding on the RatioShape rectangle. The problem is that the attached property wpflib:RatioPanel.Ratio always returns its default value, not the databound value. So I'm thinking that the attached property on RatioShape is set in the wrong "context". How do bind to the attached property so that wpflib:RatioPanel gets the bound value? <wpflib

Displaying FontFamily in Combobox

…衆ロ難τιáo~ 提交于 2020-01-01 09:50:12
问题 My goal is to manipulate the text-styles of my application via DependencyProperties. I got a diagram in which the texts are to be manipulated in size, fontfamily, color, etc. So I'd like to use an interface similar to a rich text editor like Word. I'm using this code in my TextStyleVM http://shevaspace.blogspot.com/2006/12/i-have-some-fun-with-formattedtext_14.html So I have a FontFamilyProperty and a Getter and Setter for it: public static DependencyProperty FontFamilyProperty =