Click here to Skip to main content
15,913,854 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF animation and performance Pin
User 27100917-Apr-08 18:26
User 27100917-Apr-08 18:26 
Generalfloat Dependency Property Exception Pin
RNEELY17-Apr-08 9:33
RNEELY17-Apr-08 9:33 
GeneralRe: float Dependency Property Exception Pin
Pete O'Hanlon17-Apr-08 9:55
mvePete O'Hanlon17-Apr-08 9:55 
GeneralRe: float Dependency Property Exception Pin
RNEELY17-Apr-08 10:00
RNEELY17-Apr-08 10:00 
Generalwpf xbap listbox problem Pin
pat3d216-Apr-08 9:03
pat3d216-Apr-08 9:03 
GeneralRe: wpf xbap listbox problem Pin
RNEELY18-Apr-08 4:48
RNEELY18-Apr-08 4:48 
GeneralRe: wpf xbap listbox problem Pin
pat3d223-Apr-08 7:27
pat3d223-Apr-08 7:27 
GeneralProblem with UserControl [modified] Pin
koleraba14-Apr-08 15:23
koleraba14-Apr-08 15:23 
Hi everybody

I have a problem, for which, I don't seem to find the answer
I Created a User Control, in wpf. In that control I defined a Dependency Property as(all the smaller than signs are replaced with '[', and grater than signs are replaced with ']'):

public static DependencyProperty ItemsProperty = DependencyProperty.Register("Items", typeof(ObservableCollections[SomeClass]), typeof(MyUserControl), new PropertyMetadata(new ObservableCollection[SomeClass]);

I also implemented the standard Getter / Setter for that property as

public ObservableCollection[SomeClass] Items
{
get{return (ObservableCollection[SomeClass])GetValue(ItemsProperty)};
set{SetValue(ItemsProperty, value);}
}

In the constructor of the user control I subscribe to the CollectionChanged event as:

public MyUserControl()
{
InitializeComponent();
Item.CollectionChanged += new NotifyCollectionChangedEventHandler(items_CollectionChanged);
}

and in the event handler I have the code that does what is needed

private void items_CollectionCHanged(object sender, NotifyCollectionChangedEventArgs e)
{
//Build control foreach item in e.NewItems and add them to UI and remove from UI controls foreach item in e.OldItems
}

I add UserControls to my window as follows:
[StackPanel]
[local:MyUserControl]
[local:MyUserControl.Items]
[local:SomeClass .... /]
[local:SomeClass .... /]
[/local:MyUserControl.Items]
[/local:MyUserControl]
[local:MyUserControl]
[local:MyUserControl.Items]
[local:SomeClass .... /]
[local:SomeClass .... /]
[local:SomeClass .... /]
[local:MyUserControl.Items]
[local:MyUserControl]

[/StackPanel]

From the start everything worked fine, but if I add two or more instances of MyUserControl, to the window, the first instance is OK, but the other one contains also the items that was defined in the first one. For the example above one of the UserControls whould have 2 instances of control that is build in the CollectionChanged event handler, and the other one would have 5 of them. Does anybody know how to solve this problem. Any advice will be appriciated!

Uroš

<div class="ForumMod">modified on Monday, April 14, 2008 9:33 PM</div>
GeneralRe: Problem with UserControl Pin
Insincere Dave14-Apr-08 16:33
Insincere Dave14-Apr-08 16:33 
GeneralRe: Problem with UserControl Pin
koleraba15-Apr-08 0:11
koleraba15-Apr-08 0:11 
GeneralPhoto Gallery using Silver light Pin
r aa j14-Apr-08 3:43
r aa j14-Apr-08 3:43 
GeneralRe: Photo Gallery using Silver light Pin
Michael Sync14-Apr-08 17:53
Michael Sync14-Apr-08 17:53 
GeneralRe: Photo Gallery using Silver light Pin
r aa j15-Apr-08 18:16
r aa j15-Apr-08 18:16 
QuestionHow can i use DataGridView in WPF Application? Pin
bankey101011-Apr-08 1:24
bankey101011-Apr-08 1:24 
AnswerRe: How can i use DataGridView in WPF Application? Pin
User 27100911-Apr-08 2:02
User 27100911-Apr-08 2:02 
GeneralRe: How can i use DataGridView in WPF Application? Pin
Pete O'Hanlon11-Apr-08 3:13
mvePete O'Hanlon11-Apr-08 3:13 
AnswerRe: How can i use DataGridView in WPF Application? Pin
Pete O'Hanlon11-Apr-08 2:23
mvePete O'Hanlon11-Apr-08 2:23 
GeneralRe: How can i use DataGridView in WPF Application? Pin
User 27100911-Apr-08 3:32
User 27100911-Apr-08 3:32 
GeneralRe: How can i use DataGridView in WPF Application? Pin
Pete O'Hanlon11-Apr-08 4:11
mvePete O'Hanlon11-Apr-08 4:11 
GeneralRe: How can i use DataGridView in WPF Application? Pin
User 27100911-Apr-08 4:30
User 27100911-Apr-08 4:30 
GeneralRe: How can i use DataGridView in WPF Application? Pin
Pete O'Hanlon11-Apr-08 4:51
mvePete O'Hanlon11-Apr-08 4:51 
AnswerRe: How can i use DataGridView in WPF Application? Pin
User 27100911-Apr-08 3:31
User 27100911-Apr-08 3:31 
GeneralDebugging Silverlight Pin
Edmundisme10-Apr-08 11:47
Edmundisme10-Apr-08 11:47 
GeneralRe: Debugging Silverlight Pin
Michael Sync10-Apr-08 20:34
Michael Sync10-Apr-08 20:34 
GeneralRe: Debugging Silverlight Pin
Edmundisme11-Apr-08 7:54
Edmundisme11-Apr-08 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.