I have trying to get the attached properties of a custom class which contain 1000 plus properties using MarkUpWriter. But when using MarkUpWriter for retrieving attached properties it causes more time delay. Please find the sample and screenshot regarding it below
Can you please provide any work around solution for reducing time delay or any other solution for getting attached properties of an custom class?
Code:
public partial class MainWindow : Window
{
private Stopwatch timer;
public MainWindow()
{
InitializeComponent();
Class1 viewmodel = new Class1();
timer = new Stopwatch();
timer.Start();
//Codes to get the attached properties descriptors.
Dictionary<PropertyDescriptor, DependencyProperty> markUpPropertiesList = new Dictionary<PropertyDescriptor, DependencyProperty>();
MarkupObject markupObject = MarkupWriter.GetMarkupObjectFor(viewmodel);
if (markupObject != null && markupObject.Properties != null && markupObject.Properties.Any())
{
foreach (MarkupProperty markupProperty in markupObject.Properties)
{
if (markupProperty.IsAttached && !markupProperty.IsComposite)
{
markUpPropertiesList.Add(markupProperty.PropertyDescriptor, markupProperty.DependencyProperty);
}
}
MessageBox.Show("Properties Count---"+ markupObject.Properties.Count().ToString() + "\n"+ "Total Milliseconds----"+ timer.ElapsedMilliseconds.ToString());
timer.Stop();
}
}
}
Sample Link:
https://drive.google.com/file/d/1sUxg3rwZQrOkdQmOWT6Xocb7w2SgJdmF/view?usp=sharing
Scrennshot:
For 600 properties it almost taking 600 ms time to fetch
Any suggestion to reduce time delay.
Thanks