windows-runtime

how to calculate the textbock height and width in on load if i create textblock from code?

∥☆過路亽.° 提交于 2019-12-17 09:53:44
问题 TextBlock tbl= new TextBlock(); tbl.text="Kishore"; double x=tbl.ActualHeight; double y=tbl.ActualWidth; If i execute the code from the loaded event in Metro - winRT will return 0 for both. How can I get the ActualWidth in the Loaded or SizeChanged event? 回答1: Call Measure() then Arrange() and then ActualWidth and ActualHeight will be updated. 回答2: Can also do this via UpdateLayout(); testBlock.ActualWidth This could be useful when calculating multiple objects heights and widths. 回答3:

The given System.Uri cannot be converted into a Windows.Foundation.Uri

喜欢而已 提交于 2019-12-17 09:35:56
问题 I'm trying to programmatically load a BitmapImage in a XAML Metro app. Here's my code: var uri = new Uri("/Images/800x600/BackgroundTile.bmp", UriKind.RelativeOrAbsolute); var imageSource = new BitmapImage(uri); The second line crashes with a System.ArgumentException: The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details. The link just goes to the MSDN home page, so it's no use. I've also tried removing the

DataTrigger in WinRT?

江枫思渺然 提交于 2019-12-17 07:39:40
问题 I was able to find EventTrigger in the WinRT reference, however, I wasn't able to find DataTrigger. I wasn't able to use it in an application either. Can anyone confirm that DataTrigger is really missing in WinRT? Is EventTrigger the only trigger available in WinRT? 回答1: I don't know when it changed but i have DataTriggerBehavior and GoToStateAction combining them should solve your problem... namespace imports xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:i="http:

How to check if file exists in a Windows Store App?

十年热恋 提交于 2019-12-17 07:28:49
问题 Is there any other way of checking whether a file exists in a Windows Store app? try { var file = await ApplicationData.Current.LocalFolder.GetFileAsync("Test.xml"); //no exception means file exists } catch (FileNotFoundException ex) { //find out through exception } 回答1: According to the accepted answer in this post, there is no other way at the moment. However, the File IO team is considering changing the the api so that it returns null instead of throwing an exception. Quote from the linked

WinRT/UWP Frame and Page caching: How to create new page instance on Navigate() and keep the page instance on GoBack()

僤鯓⒐⒋嵵緔 提交于 2019-12-17 07:11:48
问题 I'm trying to create an UWP (Universal Windows App) application with C#. My problem is the Frame control: If I use it without NavigationCacheMode = Required , every time the user goes back, the page is not kept in memory and will be recreated. If I set NavigationCacheMode to Required or Enabled , going back works correctly (no new page object) but if I navigate to another page from the same type, the previous page object is recycled and reused (no new page instance). Desired behavior: Is

Adding headers when using httpClient.GetAsync

為{幸葍}努か 提交于 2019-12-17 06:31:14
问题 I'm implementing an API made by other colleagues with Apiary.io, in a Windows Store app project. They show this example of a method I have to implement: var baseAddress = new Uri("https://private-a8014-xxxxxx.apiary-mock.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { using (var response = await httpClient.GetAsync("user/list{?organizationId}")) { string responseData = await response.Content.ReadAsStringAsync(); } } In this and some other methods, I need to have

UWP Based project, WebView with DOM Explorer

巧了我就是萌 提交于 2019-12-14 04:03:45
问题 I was wondering if there's such a library or if anyone could give me hints on how to implement something like this. What I want exactly is the functionality of DOM Explorer (to be more specific, when you are on any browser and hit F12 window with DOM Explorer pops where you can look through various aspects of HTML and CSS). I want to know if it would be possible to create this function for WebView and if so, any example would be appreciated. Note: I am working on Visual Studio 2015, WinRT

CollectionViewSource in windows metro app

不想你离开。 提交于 2019-12-14 03:46:13
问题 I have a collection, for which i require 3 different views 1. All data of collection 2. Grouped data (grouping criteria will be modified during application lifecycle ) 3. Filtered data (filter criteria will be modified during application lifecycle) What i want is that all views should bind to same collection so that any change to collection should be synced to all the views. With WPF, this can be achieved using CollectionViewSource. In Modern UI apps, CollectionViewSource still exists, but

winrt: load local html and its resources in webview

不想你离开。 提交于 2019-12-14 03:44:23
问题 I'm currently developing a WinRT app where I load local HTML files from Windows.Storage.ApplicationData.Current.LocalFolder . I like to know what would be the best way to load assets like Images, Audio, Video, CSS, JavaScripts, etc, that are embedded in the HTML file. Currently, I'm writing these files in the Windows.ApplicationModel.Package.Current.InstalledLocation but this wont be accessible anymore once the application had been deployed from the store or by installing the AppPackage

How to detect if a user has closed a winrt application

ε祈祈猫儿з 提交于 2019-12-14 03:42:38
问题 What is a reliable (and immediately) way to detect if a user has closed the app with ALT-F4 or the close-gesture? 回答1: According to the Application Lifecycle documentation there is no way to detect this event (See the section under "App close"). This type of state can be managed best using the ApplicationData class. 回答2: Not really an exact answer to my specific question, but a way which solved my concrete problem for which I posted my question. Maybe it helps someone else: Register to Window