silverlight

Silverlight multiple line textbox

限于喜欢 提交于 2020-02-06 05:38:25
问题 I have looked at several code snippets where people suggest that the AcceptsReturn property of a textbox in Silverlight will enable multiple lines. My problem however is when I add a textbox with said property and explicity set the height or allow it to fill the container, the text sits vertically in the middle of the textbox. <Grid x:Name="LayoutRoot" > <TextBox TextWrapping="Wrap" Text="TextBox" AcceptsReturn="True"/> </Grid> I need the text to anchor to the top of the textbox. 回答1: Ensure

Showing a text indicator before freezing the Silverlight UI thread

≡放荡痞女 提交于 2020-02-06 04:08:12
问题 At some point in my Silverlight application I need to perform a heavy operation which freezes the UI thread for about 4 seconds. Before actually performing the operation I am trying to display a simple text indicator via a TextBlock control. StatusTextBlock.Text = "Performing Some Operation..."; System.Threading.Thread.Sleep(4000); // Just as an example The problem is that the UI thread freezes before the text of the TextBlock control gets updated. How can I get the notification text shown

Problem to pass the result to the caller for asynchronous httpWebRequest

大兔子大兔子 提交于 2020-02-05 02:32:07
问题 In Silverlight I want to be able to get the output from a Helper class like this: public MainPage() { InitializeComponent(); String ouput; Helper helper = new Helper(url); Helper.invoke(output); } I can't see how to do that since in Helper Class I am obliged to do an asynchronous call: private String webserviceUrl; private XDocument xdoc = new XDocument(); public Helper(String webserviceUrl) { this.webserviceUrl = webserviceUrl; } public void invoke(ref String output) { HttpWebRequest

Silverlight飞机打飞机游戏

为君一笑 提交于 2020-02-04 16:35:25
在此白银位置打个广告:师大计算机学院的师弟师妹们加油了!师大红会加油! 操作说明 WSAD,J发射。 国庆前一天突然想写个飞机游戏,就开始疯狂coding了一天得到了一个雏形。国庆间断断续续改了些bug, 国庆完之后又拿出来玩了几天。写这个游戏的初衷也有一个原因是想学习写一下物理引擎,但是假期间借了两本物 理引擎的书,发现物理引擎无非是编程+物理领域的知识,写出一些难的东西来代码部分并不难,却对物理要求高。 失去了之前的神秘感也失去了想要加入自己写的物理引擎 的最大的动力。之后又看了游戏中的人工智能算是对 遗传算法 和神经网络了粗浅的了解。 最近这段时间也一直在反思,想想算了去把借来的一堆书还了一半,包括各种游戏编程和 其他好玩的书(分形?) ,把精力专注在一些更通用更有用的东西上,比如算法?去看计算机程序设计艺术?呵呵。 也是因为最近编程遇到了瓶颈,总是觉得突破不了。花了很多时间和精力学会了一种东西,当换到新的领域(比如说对 网络或者多线程等这种硬伤)时候,还有花费在简单debug上的时间依然花费了很多。所以我还是想尝试探索一下, 收拢些精力去看看算法和底层点的书。 从下往上的突破可能性价比_比较划算。 说了这么多废话,有图有真相。下面给出我设计的类图,无情的受到了深蓝的影响。。。 素材源自以前看到过的一个C#游戏。一并截图打包出来,想玩的可以参考一下。 C#源代码 注:这个c

How to serialize a derived class in Silverlight

不打扰是莪最后的温柔 提交于 2020-02-04 07:23:18
问题 I created a custom control in XAML, and added some custom properties as well. Now, I want to serialize it to JSON if possible. Here is (essentially) what I have: public partial class MyCustomClass : UserControl { public Dictionary<char, int[]> ValueMap; public int Value { get; set; } } And in the code that handles serialization: public static string Serialize(object objectToSerialize) { using (MemoryStream ms = new MemoryStream()) { DataContractJsonSerializer serializer = new

Dynamically setting background colour of a Silverlight control (Listbox)

不想你离开。 提交于 2020-02-04 06:45:06
问题 How do I set the background colour of items in a list box dynamically? i.e. there is some property on my business object that I'm binding too, so based on some business rules I want the background colour to be different? <ListBox Background="Red"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Background" Value="Red"/> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="5"> <TextBlock

Sending JSON Object from Javascript to Silverlight then triggering an event to update Silverlight

烈酒焚心 提交于 2020-02-04 05:34:08
问题 I am building a web application that basically consists of a set of HTML forms that, when the user updates them, updates a client-side Javascript Object Literal. That Object Literal is then converted to a JSON string and passed to the server for processing upon form submission. User fill out form -> local javascript updates client-side JS Object Literal -> user presses submit -> JS Object Literal Converted to JSON object -> JSON Posted to Server -> server processes JSON object Part of this

Silverlight Tools for Visual Studio 2008 - Placing a Control Issue

这一生的挚爱 提交于 2020-02-04 05:06:24
问题 What is the issue with the Silverlight Tools for VS2008? I can't seem to place controls on the designer surface. This didn't work for me on two different machines. Do you have to tweak the XAML to be able to place the first control? Cursor stays a compass-like-cross when over the surface. Are you supposed to drag-n-drop controls or draw them? Screenshot (as far as I got) 回答1: This is in response to your request for my thoughts on this question from your comments on this post. As both Aaron

Interaction Triggers Embedded in ContentControl

半腔热情 提交于 2020-02-03 09:02:57
问题 So to keep the question simple what I need for example is to use something like this dozens of times; <Rectangle> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <ei:ChangePropertyAction TargetName="AnotherObjectOnTheView" PropertyName="Visibility" Value="Visible" /> </i:EventTrigger> </i:Interaction.Triggers> </Rectangle> Except obviously I don't want to paste that dozens of times everywhere I need it. So I tried to plop them in a ContentControl , something like

Interaction Triggers Embedded in ContentControl

大兔子大兔子 提交于 2020-02-03 09:01:07
问题 So to keep the question simple what I need for example is to use something like this dozens of times; <Rectangle> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <ei:ChangePropertyAction TargetName="AnotherObjectOnTheView" PropertyName="Visibility" Value="Visible" /> </i:EventTrigger> </i:Interaction.Triggers> </Rectangle> Except obviously I don't want to paste that dozens of times everywhere I need it. So I tried to plop them in a ContentControl , something like