silverlight

Animate Margin Change in Silverlight

 ̄綄美尐妖づ 提交于 2019-12-23 09:25:46
问题 I am animating a border resize in Silverlight however I also need to gradually remove the margin around it (currently 50). Blend doesn't seem to generate a tween for margin change - it just jumps from 50 to 0 in one go. Is there a way to achieve this? 回答1: The problem is that a Margin is really of type "System.Windows.Thickness" which is NOT a dependency object, thus Left, Top, Right, and Bottom are NOT Dependency Properties and thus cannot be animated using DoubleAnimation (which allows for

Coloring Text in RichtextBox, C#

两盒软妹~` 提交于 2019-12-23 09:24:01
问题 How can I color new line of text with some different colors and then add it to RichTextBox? I'm using SilverLight. 回答1: You can do this in code: // Create a paragraph with two coloured runs Paragraph para = new Paragraph(); Run run1 = new Run("Red "); run1.Foreground = Brushes.Red; Run run2 = new Run("Green"); run2.Foreground = Brushes.Green; para.Inlines.Add(run1); para.Inlines.Add(run2); // Get the document FlowDocument doc = richTextBox1.Document; // Clear existing content doc.Blocks.Clear

XML serializing a list of a base class

元气小坏坏 提交于 2019-12-23 09:17:35
问题 I have class A inherits from class B . I have a list of class B that contains A and B items: List<B> myList = new List<B>(); myList.Add(new A()); When I try to serialize this list using XmlSerializable , an exception is thrown. If I define the list to of type B, then I do not get this exception. What is the best way to serialize the derived class? 回答1: XmlIncludeAttribute will do the trick. If you go to this url, you will find a code sample there too. Also, in the example the attribute is

Scrollable TextBlock Sized EXACTLY 2 Lines High

蓝咒 提交于 2019-12-23 09:05:06
问题 I need the text to display - at most -2 lines - with no vert scroll visible, then show the scroll when greater than 2 lines: <Border BorderBrush="Black" BorderThickness="1" Grid.Row="1" Grid.ColumnSpan="2"> <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="40"> <TextBlock Text="{Binding RoadsString}" Style="{StaticResource WrapTextStyle}"/> </ScrollViewer> </Border> I can experiment with the MaxHeight value until it's looks right - but I'd prefer that it accommodate whatever font is

Edit and Continue in Silverlight?

☆樱花仙子☆ 提交于 2019-12-23 09:03:10
问题 Edit-And-Continue is one of my favorite debugging tools which I have previously used on C# based Winforms and ASP.NET projects. However, I'm running a Silverlight 3.0 application on VS 2008 and whenever I try to make a change (after breaking) it says "Changes are not allowed when debugging Silverlight applications". Also there isn't an "Enable Edit and Continue" option in the project settings. Does anyone (possibly an insider) know when this feature will be supported by Microsoft??? (I NEED

Check if an event already exists

跟風遠走 提交于 2019-12-23 08:05:17
问题 I have a data grid loading row event _gridObj.LoadingRow += new EventHandler<DataGridRowEventArgs>(_gridObj_LoadingRow); and in the handler I am creating another event. In the following code how can I know if the MouseLeftBtn event already exists for that row? void _gridObj_LoadingRow(object sender, DataGridRowEventArgs e) { e.Row.MouseLeftButtonUp += new MouseButtonEventHandler(Row_MouseLeftButtonUp); } Thanks, Voodoo 回答1: Based on your comment that you don't want to attach muliple handlers

How do I truncate a string with an ellipsis in a Silverlight TextBlock?

£可爱£侵袭症+ 提交于 2019-12-23 07:56:14
问题 If I display a string too long for a TextBlock it just appears to keep writing past the edge of the TextBlock. I'd rather it use the common technique of adding an ellipsis ("...") if the text is not going to fit in the space provided. How should I go about doing this in Silverlight? The references I've found all use the TextRenderer class which is not available in Silverlight 回答1: You didn't say which Silverlight version this is. Assuming Silverlight 4, it's baked into TextBlock via the

How to bind to a singleton property in Silverlight 4?

谁都会走 提交于 2019-12-23 07:38:46
问题 Hi all first post here :) Let's start with a snippet of the code I'm using: public MyClass : INotifyPropertyChanged { private static MyClass _instance; public static MyClass Instance { get { if (_instance == null) _instance = new MyClass(); return _instance; } } private bool _myProperty; public bool MyProperty { get { return _myProperty; } set { if (_myProperty!= value) { _myProperty= value; NotifyPropertyChanged("MyProperty"); } } } private MyClass() { ... } } As you can see, it's a

SHA512 within Silverlight is not available, is there a managed library available?

元气小坏坏 提交于 2019-12-23 07:36:28
问题 SHA512Managed is missing in Silverlight (for Windows Phone 7 CTP SDK), only upto SHA256 is available for use. Does anyone know a .NET class that I could use that offers a self-contained C# or VB.net SHA512 implementation? I need to use this for authentication to a HTTP web service. 回答1: Using HashLib from http://hashlib.codeplex.com/ will work fine. There are methods within HashLib.HashFactory.HashCryptoNotBuildIn that do not require System.Crytography . 回答2: Mono has an implementation you

SHA512 within Silverlight is not available, is there a managed library available?

不羁岁月 提交于 2019-12-23 07:34:18
问题 SHA512Managed is missing in Silverlight (for Windows Phone 7 CTP SDK), only upto SHA256 is available for use. Does anyone know a .NET class that I could use that offers a self-contained C# or VB.net SHA512 implementation? I need to use this for authentication to a HTTP web service. 回答1: Using HashLib from http://hashlib.codeplex.com/ will work fine. There are methods within HashLib.HashFactory.HashCryptoNotBuildIn that do not require System.Crytography . 回答2: Mono has an implementation you