Hey Masn, I wrote code and similar conditions in my case that everything is in order. this is the case (there are many lists and named variables, differentiated by the number in the final name. Example: listAttachment1, listAttachment2, listAttachment3, .. etc.). For a better explanation of my code:
public void refreshAttachmentList (ListlistOfControlsRequest, int identifier) {
string valueName = "attachmentsField_"+identifier;
var mylistAttachment = ((FrameworkElement)System.Windows.Application.Current.RootVisual).FindName(valueName);
ListBox listAttachRequest = mylistAttachment as ListBox;
listAttachRequest.ClearValue(ItemsControl.ItemsSourceProperty);
listAttachRequest.ItemsSource = listOfAttachmentsControls;
listAttachRequest.....all properties
}
source
share