Posts Tagged ‘ Uri ’

How to Access Resources in an Assembly

new Uri("SilverlightApplication1;component/MyImage.png", UriKind.Relative)

Cross linked styles can be access in the same way!

<ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/SharedThemeAssembly;component/MyStyles.xaml"/>
            ...other ResourceDictionaries to merge in...
</ResourceDictionary.MergedDictionaries>
Advertisements

Playing Sound in Silverlight

Placing a media element in Blend and controling it’s playback is pretty simple but sometimes you just want to do it all in code.

using System.Windows.Resources;

MediaElement m = new MediaElement();
StreamResourceInfo sri = Application.GetResourceStream(new Uri("HBO_Usercontrols_XAML;component/Takeofff.mp3", UriKind.Relative));
m.SetSource(sri.Stream);
LayoutRoot.Children.Add(m);
m.Play();
VisualStateManager.GoToState(this, "ShowButtons", true);