I am currently using some MediaElements
in an application I am creating. I am dynamically creating them and adding them to a wrap panel.
The problem is I need to be able to add a key to them so I can go back and locate a specific one.
I was going to inherit from the MediaElement
and just add the key as a member. Unfortunately I can't do this because it's a sealed class.
So I tried to create a class containing a MediaElement
and the key but I can't add that to the GUI since its not a UIElement
.
Is there anyway I can do this? I just need to be able to add MediaElements
and them be able to go back and find them later so I can modify or remove them.
There is such way. Add
Dictrionary <string, MediaElement>
to your form. When adding new media element, add it to the dictionary either. When you'll need to access the MediaElement you can query it from dictionary by using it's key name. You'll get the reference to your element that is at the same time in dictionary and on GUI.And when deleting from GUI, don't forget to delete element from dictionary either.