1. As the name suggests, LINQ is a query, it is preferred not to have side effects.
2. Use Any() instead of Count() > 0 when you need to find out if a list is not empty.
This storyboard works when the storyboard is stored in the resources
of the window which holds the storyboard target. The 'From' value is
correctly bound to the ActualWidth of the host Window instance.
However, I need to store the storyboard in my application level
resources. From here, the storyboard does not seem to be able to target
the window to determine the 'From' property. This is understandable as
from inside , the binding won't be able to find an 'ancestor' of type Window.
I guess I need to be able to bind the 'From' value, relative to the
target of the animation, rather than relative to the storyboard's DoubleAnimation.
I'm trying to make a storyboard as an application resource where I can set a variable objects such as TO and FROM color transitions, the length of time between transitions, this seems like a good candidate:
I'm trying to bind from Button's ContentTemplate to attached
property. I read all the answers for question similar to "binding to
attached property" but I had no luck resolving the problem.
Please note that example presented here is a dumbed down version of
my problem to avoid cluttering the problem with business code.
So, I do have static class with attached property:
using System.Windows;
namespace AttachedPropertyTest{publicstaticclassExtender{publicstaticreadonlyDependencyPropertyAttachedTextProperty=DependencyProperty.RegisterAttached("AttachedText",typeof(string),typeof(DependencyObject),newPropertyMetadata(string.Empty));publicstaticvoidSetAttachedText(DependencyObject obj,string value){
obj.SetValue(AttachedTextProperty, value);}publicstaticstringGetAttachedText(DependencyObject obj){return(string)obj.GetValue(AttachedTextProperty);}}}
That's pretty much it. I would expect t see "Attached" in the middle of the button.
Instead it crashes with: Property path is not valid. 'Extender' does not have a public property named 'AttachedText'.
I've set breakpoints on SetAttachedText and GetAttachedText, and SetAttachedText is
executed, so attaching it to button works. GetAttachedText is never
executed though, so it does not find property when resolving.
My problem is actually more complicated (I'm trying to do binding
from inside of Style in App.xaml) but let's start with the simple one.
Did I miss something?
Thanks,
While I can't confirm for sure that your requirement will work, I can confirm that as long as you set the Grid.IsSharedSizeScope Attached Property to True on a parent container control of both of the Grids that you have set up SharedSizeGroups for, then it should
work. To find out for sure, just try it out... you could have probably
tested it yourself quicker than the time it took you to write this
question.
If there is no parent container control at the moment, just add one.... (put everything into it).
The important thing to note here is that you're only supposed to set Grid.IsSharedSizeScope to True on the one single parent container control and not on every Grid.
SET Grid.IsSharedSizeScope in the PARENT control! NOT ON THE GRID ITSELF!
Hopefully this will save someone else time. I found there are multiple
properties that have to be set to 0 in order to completely remove the
spacing between ListViewItems in a ListView control. In addition to
Margin and Padding I had to set the BorderThickness to 0.