C# - DependencyProperty Keeps It's Value After Destruction

Aug 26, 2010

Scenario: A VB6 library calls a method in a .NET-Assembly through COM and with that opens a WPF-Dialog, which is contained in another .NET-Assembly that is early bound. This WPF-Dialog got a complex master/detail implementation over a DependencyProperty of type ObservableCollection on this dialog. The DependencyProperty looks something like this:

public static readonly DependencyProperty ThatDependencyPropertyProperty =
DependencyProperty.Register("ThatDependencyProperty", typeof(ObservableCollection<SomeClass>)

[Code]....

Problem: After this dialog gets closed through setting DialogResult and is being completely re-instantiated, this DependecyProperty still got it's values and the dialog is still displaying the previous master/detail information. My current workaround is to simply let the dialog clear the collection in it's ctor, but I certainly don't like this... what could keep this collection alive through two instantiations?

View 1 Replies


ADVERTISEMENT

String Manipulation And Preventing Variable Destruction?

Oct 17, 2009

I've made a class that's supposed to manipulate strings in a textbox to turn them into integers and let the cursor return to the place it was before a character was removed. It seems to work fine as far I've been able to figure out, but when I use it from the TextChanged event things go wrong. The problem is that when the class is finished and the corrected string is written back into the textbox, the TextChanged event is fired again. That on itself is not the worst problem as it runs too quick to notice, but the disadvantage is that a variable needed is destroyed with the class after it's finished the first time, resulting in the cursor ending up in the wrong place at the left of the textbox after it's run for the second time.I've been thinking of 3 solutions, but none of them I've been able to find out how to put it in code or even if they are possible:

[Code]...

View 11 Replies

Attaching A Custom DependencyProperty To A StackPanel In WPF?

Jul 7, 2010

I'm trying to make a mouse over for a stack panel in WPF using a custom DependencyProperty (StackPanels do not handle the MouseEnter event).

I've created a class for the DependencyProperty like so:

Public Class MouseEnterBehavior
Public Shared Property MouseEnterProperty As DependencyProperty =
DependencyProperty.RegisterAttached("MouseEnter",

[Code]....

I was able to get the code to compile and run, however the binding doesn't occur.

View 2 Replies

Wpf - DependencyProperty Callback-Method Not Called

Nov 29, 2009

I create a UserControl (TableWithFilter.xaml) with a dependency property (source). The UserControl is a Table with a source property for the different items. I created the XAML and set the source property via the XAML Binding. So far so good.

But if the value of the dependency property is changed, the defined callback method is not called. Therefore I cannot update the entries in my table. Has anyone an idea why the callback method is not called?

Here is the definition of my property in the class "TableWithFilter":

Public Shared ReadOnly SourceProperty As DependencyProperty = _
DependencyProperty.Register("Source", GetType(List(Of TableViewItem)), GetType(TableWithFilter), _

[Code]....

If the attribute "ContentList" is changed I expet that the "ChangeSource" method in the TableWithFilder class is called. But this is not the case. After I changed the ContentList attribute, I Raise the following Event:

RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("ContentList"))

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved