Following up on The ultimate hack for Silverlight in Blend post from Josh Smith, I tried to make Blend display pictures from the My Pictures folder right in my Silverlight application. Needless to say, it worked as advertised :)
The ViewModel is set through d:DataContext:
public class MainPageViewModel
{
public MainPageViewModel()
{
SetLocalPictures();
}
private void SetLocalPictures()
{
string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
IEnumerable<string> pictures = Directory.EnumerateFiles(folder);
Pictures = (
from p in pictures
select new Uri(string.Format("file://{0}", p.Replace('\\', '/')), UriKind.Absolute)
).ToArray();
}
public Uri[] Pictures { get; set; }
}
The thing is that this code wouldn’t work with Silverlight application running in a non-trust mode – it would throw a security exception. However, setting this ViewModel as the run-time DataContext and running with elevated permissions, the pictures would get displayed as well.
And of course this works in Visual Studio 2010 designer too:

A nice alternative for Blend’s sample data…
e6d28640-ff22-4d8d-82ba-76769089191b|4|2.0|27604f05-86ad-47ef-9e05-950bb762570c
Tags :