microsoft-metro

Working with hmacsha256 in windows store app

孤者浪人 提交于 2019-12-05 03:35:55
I'm migrating/converting/rebuilding a Windows Phone 7.1 app to a Windows 8 Store App. One method I am using in de WP7 app is giving me trouble: private byte[] GetSHA256Key(string data, string secretKey) { byte[] value = Encoding.UTF8.GetBytes(data); byte[] secretKeyBytes = Encoding.UTF8.GetBytes(secretKey); HMACSHA256 hmacsha256 = new HMACSHA256(secretKeyBytes); byte[] resultBytes = hmacsha256.ComputeHash(value); return resultBytes; } Looking at the documentation for Windows Store Apps I came up with this new code which I hoped would give the same result. But, no. I'm doing something wrong.

Can't register a Time triggered Background Task

偶尔善良 提交于 2019-12-05 03:11:25
For a Windows 8 App, in C#/Xaml I try to register a background task. It's hard to tell but I guess my background task is well registred but when I click on the name of my background task on the Debug Location Toolbar my app stops working without any message. I looked at the log on the Event Viewer and I get : "The background task with entry point MyApp.Pages.SampleBackgroundTask and name Example hourly background task failed to activate with error code 0x80010008." Here is my code : private async void Button_Click_BackgroundTask(object sender, RoutedEventArgs e) { string entryPoint = "MyApp

WinRT - How to ignore or delete page from navigation history

南笙酒味 提交于 2019-12-05 02:57:46
I have following situation in my WinRT metro (c# - xaml) application : User launch the application and he or she is not logged in. In the menu bar I have button which navigates them to Shopping cart. It's important to mention that they can click on it regardless of logged in/out status. So I have this : Home Page - > Login Page - > Shopping Cart And everything works great, but when I try press BACK button on my Shopping Cart page I'm navigated back to Login Page, which make sense, because page is in my navigation history. But I don't want that, I want to return user to Home Page and skip login

Display a StorageFile in Windows 8 Metro C#

允我心安 提交于 2019-12-05 02:20:36
问题 I would like to display an image file on the UI from the Assets. I managed to store the item as a StorageFile . How can I display it? I've tried to display it in a XAML <Image> tag's Source. Is it possible to covert StorageFile to Image ? string path = @"Assets\mypicture.png"; StorageFile file = await InstallationFolder.GetFileAsync(path); 回答1: Try this function public async Task<Image> GetImageAsync(StorageFile storageFile) { BitmapImage bitmapImage = new BitmapImage();

WinRT Xaml ListView - Touch doesn't scroll well

喜夏-厌秋 提交于 2019-12-05 00:51:06
问题 I have a horizontal list view that scrolls offscreen to the right, such as this: The problem is, when using touch you can't swipe to scroll the ListView by default, it seems to just grab the ListView item and pull it horizontally a little bit. The only way I can get it to scroll is to click the 5-10 pixels in between each ListViewItem, which is horrible. Is there a setting to modify this behavior? My Xaml is basically this: <ListView x:Name="listView" Grid.Column="1" IsItemClickEnabled="True"

Open links in external browser in WebView (WinRT)

▼魔方 西西 提交于 2019-12-05 00:45:13
I have a WebView component that I use to display HTML Ads in my app. When user clicks an Ad in the WebView I want to open the Ad link in an external browser. How do I do that? I need something like OnNavigating from the WP7 browser. I tried the Tapped event of the WebView but it never gets called even when I set IsTapEnabled=true. I need something like You will need to use the ScriptNotify event for this. Here's how I handled the scenario (using NavigateToString). If you're retrieving the web view content from a URL, you will need be able to modify the HTML for this to work. Add the following

Getting a Stream from a resource file / content

南笙酒味 提交于 2019-12-04 23:33:55
Is this the correct/only way of getting a Stream from a resource file? Uri uri = new Uri(fullPath); StorageFile storageFile = await Windows.Storage.StorageFile. GetFileFromApplicationUriAsync(uri); IRandomAccessStreamWithContentType randomAccessStream = await storageFile.OpenReadAsync(); IInputStream resourceStream = (IInputStream) randomAccessStream.GetInputStreamAt(0); All my other sources (http and local storage) return a Stream object, and it is painful to have to if-else code that uses one or the other. I've also tried to just create a MemoryStream out of it, but I can't even find a way

Why does TextBlock trims ending spaces from the text?

安稳与你 提交于 2019-12-04 23:13:46
Here is my TextBlock s <StackPanel Orientation="Horizontal" Margin="0,3,0,0"> <TextBlock Text="6 or more characters, at least one letter and a number, " FontFamily="Segoe UI" Foreground="#000000" FontSize="13"/> <TextBlock Text="no symbols" FontFamily="Segoe UI" Foreground="#000000" FontSize="13"/> </StackPanel> And here is the output (screen shot) Why TextBlock trims ending spaces? However it works fine when I give leading spaces. It looks like xml:space="preserve" should do the trick (see Preserving Whitespace in XAML ) but that doesn't seem to be working in a Windows Store app (it does in

Crop image with dynamic rectangle coordinate

这一生的挚爱 提交于 2019-12-04 22:48:42
I have a Image and I want crop it by using a rectangle, code below is the code I put a image and draw a rectangle at middle of the image: MainPage.Xaml: <Canvas x:Name="canvas" HorizontalAlignment="Center" VerticalAlignment="Center" Width="340" Height="480" Background="Blue"> <Image x:Name="photo" HorizontalAlignment="Center" VerticalAlignment="Center" ManipulationMode="All"> <Image.RenderTransform> <CompositeTransform/> </Image.RenderTransform> </Image> <Path Stroke="Black" StrokeThickness="1"> <Path.Data> <RectangleGeometry Rect="0,0,340,480"/> </Path.Data> </Path> </Canvas> I able to move

Windows 8 & MySQL? What are my options?

大城市里の小女人 提交于 2019-12-04 22:41:34
I am currently writing a Metro application and I want to integrate managed SQL handling within my app by connecting it to my web SQL DB. What are my options for .NET 4.5? Also, if you downvote, please explain why, I know there is some MySQL connector for .NET 4, but it is obviously incompatible with 4.5 I strongly advise against client programs connecting directly to a database server over the Internet, for the following reasons: Client libraries are designed and built around the assumption that the database is under a few miliseconds away, especially very chatty protocols (MSSQL is amongst