I have been searching for DAYS for material explaining how to do this...
I have a code in WPF (C#) that loops through a collection of FrameworkElements. The objective is to save each of the FrameworkElements as separate images (gif files). The code is working currently and does in fact save all of the images I need.
However, the user has to manually click the "Save" button in the SaveFileDialog
box for EACH element. There are over 100 elements. I want the code to Open the SaveFileDialog
box and automatically "click" the "Save" button for the user throughout the loop (ie - for each element).
Here is the code currently...
foreach(FrameworkElement x in y)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = " ...blah...";
dlg.DefaultExt = "...blah..";
Nullable<bool> result = dlg.ShowDialog(); // (A)
string path = dlg.FileName;
int selectedFilterIndex = dlg.FilterIndex;
if(result == true) // (B)
{ ... then do all the rendering, cropping, etc.. .. }
}
I know that I can write some line in between the line containing "(A)" and "(B)" that will activate the "Save" button. I cannot find any examples online that eliminate the "if" statement.
I don't want my code to "wonder if this result will be true". I want the code to actually set the result to true regardless of anything else.
Any help is greatly appreciated.