in XamlControlsGallery/Controls/ControlExample.xaml.cs [331:367]
string GetBestScreenshotName()
{
string imageName = "Screenshot.png";
if (XamlSource != null)
{
// Most of them don't have this, but the xaml source name is a really good file name
string xamlSource = XamlSource.LocalPath;
string fileName = Path.GetFileNameWithoutExtension(xamlSource);
if (!String.IsNullOrWhiteSpace(fileName))
{
imageName = fileName + ".png";
}
}
else if (!String.IsNullOrWhiteSpace(Name))
{
// Put together the page name and the control example name
UIElement uie = this;
while (uie != null && !(uie is Page))
{
uie = VisualTreeHelper.GetParent(uie) as UIElement;
}
if (uie != null)
{
string name = Name;
if (name.Equals("RootPanel"))
{
// This is the default name for the example; add an index on the end to disambiguate
imageName = uie.GetType().Name + "_" + ((Panel)this.Parent).Children.IndexOf(this).ToString() + ".png";
}
else
{
imageName = uie.GetType().Name + "_" + name + ".png";
}
}
}
return imageName;
}