I'm still in the beginning stage of learning c#, so i have a question about a part of my code. I strongly have the feeling there should be a way smarter way to accomplish what i try to do:
So what do i have: A WPF window, with a whole bunch of images on it. At the start, i want them all to be set to Hidden, so at the initialize part of the window, i set them all hidden and do it like this:
.....
IMx01y01W.Visibility = Visibility.Hidden;
IMx23y73W.Visibility = Visibility.Hidden;
IMx31y21W.Visibility = Visibility.Hidden;
IMx03y16W.Visibility = Visibility.Hidden;
.....
There is a logical in the names of the images like IMx##y##W, where the ## are the variable numbers.
As stated above, i strongly have the feeling that there should really be some smarter way to do this.
=======
EDIT 1
Ok so far i ended up with this:
foreach (object obj in LogicalTreeHelper.GetChildren(this))
{
if (obj is Image)
{
Image obj = (Image)item;
obj.Visibility = Visibility.Hidden;
}
//do something
}
The part in the if statement is totally wrong, but i don't know how to go on on this point. can anyone push me a bit more in the right direction ? thanx!