You could use attached dependency property to implement this kind of behavior...Josh Smith has a good article on attached behaviors in WPF.
lneir
Posts
-
implement Dock behaviour -
Pattern for null settingsYes, I don't see a direct way to get MyProperty set back when unchecked. I'll have to think about that one.
-
Pattern for null settingsYou could use mult-binding to achieve this...something like this should work...here using a multi-binding with a converter on the text property of the TextBlock. Multi-binding allows us to bind (of course) to multi-items and the converter handles the trick of looking at the value of the check box to see if we should return null or the property value.
CheckMe namespace Property { /// /// Interaction logic for Window1.xaml /// public partial class Window1 : Window, INotifyPropertyChanged { String _myProperty; public String MyProperty { get { return _myProperty; } set { _myProperty = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("MyProperty")); } } public Window1() { InitializeComponent(); MyProperty = "Nothing"; DataContext = this; } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion } public class CheckBoxConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { string name; bool isChecked = (bool)values[0]; String myProperty = values[1] as String; if (!isChecked) name = "not checked"; else name = myProperty; return name;
-
WPF faster DrawingVisuals initialization.This is an old discussion but might be helpful for you: drawingcontext very slow many geometries
-
Do we have a something like MASK effect (in SwishMax or Flash) in WPF?Here is some xaml that will animate an ellipse across the text...basically using visual brush to set the fill property of a TextBlock. Then I animate the Left and Top property of ellipse contained in the visual brush. Since a visual brush can be anything you could put image or video here also, basically any visual you want. Enjoy...
-
Shadow in XAML ?FYI...if you are using .net 3.5sp1, you should move to using the new UIElement.Effect rather than the old UIElement.BitmapEffect. The new effects are hardware rendered - very fast! The old bit map effects are software rendered - slow!!! I believe there is a backwards compatibility mode so you can still use BitmapEffect for now in 3.5sp1 but it will go away eventually.
-
How can I create this effect in WPF ?Adam Nathan has an example of aero glass integrated with WPF: http://blogs.msdn.com/adam_nathan/archive/2006/05/04/589686.aspx[^] Also, with the new effects in 3.5 sp1, you can create blurr effects that are hardware rendered: http://www.codeplex.com/wpffx[^]
-
Running a method in secondary second of a storyboard ?Can you provide a few more details? Are you talking about starting another storyboard when the first storyboard reaches a particular time? Easiest method might be to break the first storyboard up into two parts and when the completed event fires on the first half your could start the other storyboard.
-
Calling Old Class Library in Silverlight Application.Yes, just create silverlight class library. Put your class(es) in there and compile. Then you can reference that dll from any silverlight project. Note, silverlight contains a subset of .net.
-
Silverlight listening to a .NET Control EventYou can only reference DLLs compiled in SL from SL projects. So, you will need to build the DLL you trying to reference in SL. SL contains a subset of .net (as well a subset of WPF).
-
how can i read files from my silverlight 2 web folder