Skip to content

Instantly share code, notes, and snippets.

View wtuts's full-sized avatar

Windows App Tutorials wtuts

View GitHub Profile
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/SharedResources.xaml" />
<ResourceDictionary Source="Themes/PlatformSpecificThemes.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<Style x:Key="MyTextBlockStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="Green"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Margin" Value="12"/>
</Style>
<Style x:Key="MyTextBlockStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="Red"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Margin" Value="12"/>
</Style>
<TextBlock Text="Hello World!!" Style="{StaticResource MyTextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
ToastService.ShowToastNotification(MyTextBox.Text);
}
public class ToastService
{
public static void ShowToastNotification(String message)
{
ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
// Set Text
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
toastTextElements[0].AppendChild(toastXml.CreateTextNode(message));
<StackPanel Margin="12" VerticalAlignment="Center">
<TextBox x:Name="MyTextBox"/>
<Button Content="Toast" HorizontalAlignment="Stretch" Click="ButtonBase_OnClick"/>
</StackPanel>
public async void SaveThumbnail(StorageFile videofile, string thumbnailfilename)
{
var thumbnail = await videofile.GetThumbnailAsync(ThumbnailMode.VideosView);
var saveFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(thumbnailfilename, CreationCollisionOption.GenerateUniqueName);
var inputBuffer = new Windows.Storage.Streams.Buffer(2048);
using (var destFileStream = await saveFile.OpenAsync(FileAccessMode.ReadWrite))
{
IBuffer buf;
public async Task<BitmapImage> FetchThumbnail(StorageFile videofile)
{
//Fetching the thumbnail in form of StorageItemThumbnail
var thumbnail = await videofile.GetThumbnailAsync(ThumbnailMode.VideosView);
var inputBuffer = new Windows.Storage.Streams.Buffer(2048);
IBuffer buf;
IRandomAccessStream stream=new InMemoryRandomAccessStream();
public async void CopyFileToFolder(StorageFile filetoCopy, StorageFolder folder)
{
await filetoCopy.CopyAsync(folder);
}