windows-phone-7

How to set a default source for an Image if binding source is null?

孤街醉人 提交于 2020-01-01 01:56:06
问题 I'm using binding for source of an Image control. <Image Source="{Binding ImageUri}"/> But this ImageUri can be null, therefor I want to use a default image, a place holder, for that, which can be in /Assets/PlaceHolder.png for example. How can I set a default image? thanks. (It's a WP8 app, but should not be different of WPF) 回答1: You can achieve it by setting TargetNullValue <Image> <Image.Source> <Binding Path="ImageUri" > <Binding.TargetNullValue> <ImageSource>/Assets/PlaceHolder.png<

ApplicationBarIconButton is null

烂漫一生 提交于 2020-01-01 01:16:29
问题 Why is my ApplicationBarIconButton null? <phone:PhoneApplicationPage.ApplicationBar> <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" x:Name="appBar"> <shell:ApplicationBarIconButton x:Name="appbarSave" IconUri="/Icons/appbar.save.rest.png Text="Save" IsEnabled="False" Click="appbarSave_Click" /> </shell:Application Bar> </phone:PhoneApplicationPage.ApplicationBar> The appBarSave object is null, and trying this: Initialize Component(); appbarSave.IsEnabled = true; Results in a

WP7 — NavigationService.Navigate is complaining that it is not receiving an object reference . . . but why?

家住魔仙堡 提交于 2019-12-31 21:27:18
问题 WP7 newb question here. I have the following code: public class KeyboardHandler : INotifyPropertyChanged { // lots of methods here public void FunctionKeyHandler() { Uri targetUri = new Uri("/View/SelectTable.xaml",System.UriKind.Relative); NavigationService.Navigate(targetUri); } // more methods } I am getting an error: "Error 1 An object reference is required for the non-static field, method, or property 'System.Windows.Navigation.NavigationService.Navigate(System.Uri)' Why? 回答1: The

Silverlight Windows Phone 7: Load Images From URL

好久不见. 提交于 2019-12-31 21:21:34
问题 I got the code below that is trying to load an image from the web into an Image control, when I run it I get an error on the given line that no network access is allowed: private void button1_Click(object sender, RoutedEventArgs e) { WebClient webClientImgDownloader = new WebClient(); webClientImgDownloader.OpenReadCompleted += new OpenReadCompletedEventHandler(webClientImgDownloader_OpenReadCompleted); webClientImgDownloader.OpenReadAsync(new Uri("http://dilbert.com/dyn/str_strip/000000000

How to wrap a website in a phone app?

偶尔善良 提交于 2019-12-31 10:18:34
问题 I have seen a lot of mobile phone apps that just open a web page without the controls. Just the page. I am looking for guidance and links to start something simple like this. 回答1: If I understand what you're asking for, on Windows Phone 7 you cannot get such an application approved in the Microsoft Marketplace. Section 2.10 of the Application Certification Requirements for Windows Phone says "Your application must have distinct, substantial and legitimate content and purpose. Your application

How to determine the keyboard offset

霸气de小男生 提交于 2019-12-31 07:52:05
问题 I had this issue yesterday and it seems a lot of people have had similar issues in the past, so I figured I would pose my question & the solution I ended up coming up with. Microsoft has cleaner solutions to this in the 8.1 SDK, but the vast majority of WP app users are on 8.0 and below, so I imagine this will still be helpful. When you open the virtual keyboard in a Windows Phone 7/8 Silverlight app, and the text box that caused the keyboard to open is on the lower half of the screen (that

How to determine the keyboard offset

♀尐吖头ヾ 提交于 2019-12-31 07:51:58
问题 I had this issue yesterday and it seems a lot of people have had similar issues in the past, so I figured I would pose my question & the solution I ended up coming up with. Microsoft has cleaner solutions to this in the 8.1 SDK, but the vast majority of WP app users are on 8.0 and below, so I imagine this will still be helpful. When you open the virtual keyboard in a Windows Phone 7/8 Silverlight app, and the text box that caused the keyboard to open is on the lower half of the screen (that

Connect to XML file at web address for WP7 app

别说谁变了你拦得住时间么 提交于 2019-12-31 07:15:53
问题 I've been trying to learn the ins-and-outs of Windows Phone 7 programming over the past few weeks. I have learned most of the basics but I've been having trouble finding a tutorial explaining exactly how to do something with XML. I want to create a very basic app which accesses an XML file at a web address and displays the various items within the file as text within the app. I've come across several tutorials which all seem to do it in a different way, or aren't explaining exactly the thing

In C# on windows phone Attempt to access the method failed: System.IO.FileStream..ctor(System.String, System.IO.FileMode)

梦想的初衷 提交于 2019-12-31 07:10:13
问题 FileStream FS = new FileStream("MyFolder\\MyFile.txt", FileMode.Open); IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream("MyFolder\\MyFile.txt", FileMode.Append, myIsolatedStorage)); using (writeFile) { FS.Seek(0, SeekOrigin.End); writeFile.WriteLine(txtWrite.Text); writeFile.Close(); System.Diagnostics.Debug.WriteLine("Now I am here"); } When I am trying to run this code(trying to

WP7 XNA game: how to adapt to different phone resolutions?

陌路散爱 提交于 2019-12-31 06:49:04
问题 I've created a game that targets the 800 x 480 resolution, but have become interested in having it adapt to other WP7 resolutions. Also, I've heard that games can be ported to iPhone and Android through Mono and ExEn, opening up a ton of other screen resolutions. What is the proper way to deal with this? I'd like to make the game smart enough to detect the screen size and alter the assets to look as close to the original as possible and play the same. This is a 2D game and I would think the