silverlight

Operation not permitted on IsolatedStorageFileStream. error

那年仲夏 提交于 2019-12-17 16:45:30
问题 I have a problem with isolated storage. This is my code: List<Notes> data = new List<Notes>(); using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream isoStream = isoStore.OpenFile("Notes.xml", FileMode.OpenOrCreate)) { XmlSerializer serializer = new XmlSerializer(typeof(List<Notes>)); data = (List<Notes>)serializer.Deserialize(isoStream); } } data.Add(new Notes() { Note = "hai", DT = "Friday" }); return data; the mistake :

How to change x,y origin of canvas to bottom left and flip the y coordinates?

邮差的信 提交于 2019-12-17 16:34:23
问题 I have a bunch of data points that I would like to two-way bind to points on a canvas. The points assume larger y values are reflected in an upwards direction like most math graphs. How do I change the x,y origin of the canvas to the bottom left corner and reverse it's interpretation of the y coordinate? (I would like to stay in XAML) 回答1: <Canvas> <Canvas.LayoutTransform> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX=".5" CenterY=".5" /> </Canvas.LayoutTransform> </Canvas> 回答2: I tried the

Windows Phone 7: Highlight Selected Listbox item

与世无争的帅哥 提交于 2019-12-17 16:27:41
问题 I have the following XAML (simple list box with custom DataTemplate). I'm trying to figure out how to highlight the selected item (maybe background colour change). I figure I need to do something with Styles in Expression Blend but I'm not quite sure where to start... Edit: After a bit of playing around I now have this (which doesn't seem to do anything) <phone:PhoneApplicationPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx

Windows Phone 8 Panorama SelectionChanged & Databinding

跟風遠走 提交于 2019-12-17 16:26:39
问题 I wrote an app for Windows Phone 7, recently I've upgraded it to Windows Phone 8 and I plan on adding some features. Unfortunately, I've run into a problem immediately after the upgrade. The main part of the app is a Panorama control that is databound. On SelectionChanged I am fetching the data for the new PanoramaItem + 1 (preselecting data so it's there when the person eventually goes to the item). That worked fine in WP7 but the SelectionChanged event doesn't fire with WP8. I've reproduced

Best way to read through xml

China☆狼群 提交于 2019-12-17 15:56:10
问题 HI I have a xml document like this: <Students> <student name="A" class="1"/> <student name="B"class="2"/> <student name="c" class="3"/> </Students> I want to use XmlReader to read through this xml and return a list of students as List<student> . I know this can be achieved as follows: List<Student> students = new List<Student>(); XmlReader reader = XmlReader.Create("AppManifest.xml"); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "student") { students

Silverlight 3: ListBox DataTemplate HorizontalAlignment

試著忘記壹切 提交于 2019-12-17 15:47:22
问题 I have a ListBox with it's ItemTemplate bound to a DataTemplate. My problem is I cannot get the elements in the template to stretch to the full width of the ListBox. <ListBox x:Name="listPeople" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,0,0,0" Background="{x:Null}" SelectionMode="Extended" Grid.Row="1" ItemTemplate="{StaticResource PersonViewModel.BrowserDataTemplate}" ItemsSource="{Binding Mode=OneWay, Path=SearchResults}" > </ListBox> <DataTemplate x:Key=

Making the Silverlight XAP file expire from browser cache programmatically

时间秒杀一切 提交于 2019-12-17 15:36:25
问题 How to do I prevent a Silverlight XAP file being cached by the web browser? The reason I want to do this is during development I don't want to manually clear the browser cache, I'm looking for a programmatic approach server side. 回答1: Using IIS management add a custom header Cache-Control with the value no-cache . That'll cause the browser to check that any cached version of the XAP is the latest before using it. 回答2: Add a query parameter to the URL for the XAP in the element on the HTML

Why dependency properties?

半城伤御伤魂 提交于 2019-12-17 15:27:21
问题 Why did Microsoft go the route of making dependency properties and dependency objects instead of using reflection and maybe attributes? 回答1: This helped me understand the reasoning: The main difference is, that the value of a normal .NET property is read directly from a private member in your class , whereas the value of a DependencyProperty is resolved dynamically when calling the GetValue() method that is inherited from DependencyObject . When you set a value of a dependency property it is

Hiding inherited members

戏子无情 提交于 2019-12-17 11:18:07
问题 I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency properties which have become vestigial and can be a little confusing when using IntelliSense or using the classes in a visual designer. These classes are all controls that are written to be compiled for either WPF or Silverlight 2.0. I know about ICustomTypeDescriptor and ICustomPropertyProvider , but

How to inject Javascript in the WP7 WebBrowser control?

狂风中的少年 提交于 2019-12-17 09:57:58
问题 I can inject JavaScript in WebBrowser control in C# windows form by this link How to inject JavaScript in WebBrowser control? But I can't do this in WP7, please help me. 回答1: Unfortunately WebBrowser.Document is not available on WP7. But you can create and call a JavaScript function using InvokeScript . Have a look over here where I describe how. In short: you don't use .Document and C# but create a piece of JavaScript instead. You then call eval with this script as parameter to invoke it.