andyBlog [andy britcliffe]

Blogtastic

  • Getting ready for IE8

    With BillG announcing IE8 Beta 2's arrival in August Jefferson has a great post on the IE Blog explaining how to ensure your web apps correctly render with IE8.

    I'd especially recommend reading and understanding the explanation around "X-UA-Compatible: IE=7" and "X-UA-Compatible: IE=EmulateIE7" meta tags.

    Enjoy.

  • Detecting network activity with IE8 Beta 1

    So I've been having a dig around the developer experience with the new IE8 beta 1 we released back at Mix 08 and one of the cool features I've come across is genuine network connectivity detection.

    Previously with IE you were only able to detect if the user had set IE to offline mode explicitly and would not be able to detect if a network connect was or wasn't present.

    However this has now all changed as calling alert(window.navigator.onLine) will give you a honest true or false as to whether there is network connectivity. Added to this is that IE8 gives you a couple of event handlers to notify the browser (and hence you webpage) when the connectivity status changes.

    Here is a very simple example of a basic web page with the handlers wired up to alert on change of connection status:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Test IE8 Online/Offline notification</title>
    
        <script type="text/javascript" language="JavaScript">    
            function offline()
            {
                alert("offline with IE8");
            }
            
            function online()
            {
                alert("online with IE8");
            }  
        </script>
    
    </head>
    <body onoffline="offline()" ononline="online()">
        <p>Disconnect and reconnect your network to see the alert status</p>
    </body>
    </html>
  • Silverlight 2: Generate Images on the fly

    Joe Stegman has been hard at work making this happen and has now released an initial version of his PNG image generator here.

    Very cool - Great work Joe!!

  • Silverlight 2: Web Services

    The product team have just fired up a blog on this topic. Worth adding to your favourite feed reader.

  • Silverlight 2: accessing default control templates

    As you dig deeper with Silverlight 2 you will start to want to customise some of the built in controls. Now a nice way to start working with a new style I've found in WPF land is begin with the default template in place and then tweak from there. Now in WPF this is really easy to do with Blend but in SL 2 it's currently a little more involved by either reflectoring the Silverlight Controls dll and examining the generic.xaml resource or by accessing the styles on MSDN here.

    However a neat alternative is a very cool WPF tool over at Delay's blog that gives you access to these templates - handy stuff!!

  • Silverlight 2 ListBox, ListBoxItem, ScrollViewer, and ScrollContentPresenter - from the horses mouth.

    If you're digging into Silverlight 2 and the controls available then you should check out Delay's blog as he has produced a great FAQ/notes post on the controls he was working on for Silverlight 2 Beta 1.

    Well worth a read.

  • Using ObservableCollections and DataBinding with Silverlight 2

    So hot on the heels of the announcement of Silverlight 2 Beta 1 at Mix08 I wanted to show you two of the coolest features (in my opinion) available to you now to play with. New to the feature set of Silverlight 2 is DataBinding and Observable Collections. For those of you who are familiar with WPF you will be well aware of the benefits of the two features mentioned.  For those not, there is a nice article here that explains in more detail.

    I really wanted to explore these in Silverlight so I've produced a simple code example that shows the use of these two features in the Beta 1 release. I really think it gives a very powerful indication of the direction of Silverlight and also the possibilities for creating truly Rich Internet Applications. It also demonstrates the goal of the product team to really have a WPF feature set in Silverlight.

    The demo contains an ItemsControl that is declaratively data bound to a ObservableCollection of strings. The example then shows that directly manipulating the collection (adding/removing items) is automagically reflected in the UI without the need to touch any of the user interface or binding mechanism. If you've lived in the world of AJAX development you should immediately see the power of this compared to a trying to do this kind of behaviour through JavaScript.

    So we start by defining a StackPanel containing an ItemsControl which will display our collection and apply the Data Binding syntax in our Xaml.

    <UserControl x:Class="BindingAndCollectionsEx.Page"
        xmlns="http://schemas.microsoft.com/client/2007"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Width="400" Height="300">
        <StackPanel>
            <ItemsControl x:Name="itemsControl">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            <Button Width="100" Height="50" Background="RoyalBlue" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" Content="Click" />
        </StackPanel>
    </UserControl>

    Then in our code behind we create our collection and set the ItemsControl source to the collection and the declare the mouse click event to add items to the collection.

    public partial class Page : UserControl
        {
            ObservableCollection<string> collection = new ObservableCollection<string>();

            public Page()
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(Page_Loaded);
            }

            /// <summary>
            /// Handles the Loaded event of the Page control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
            void Page_Loaded(object sender, RoutedEventArgs e)
            {
                this.collection.Add("One");
                this.collection.Add("Two");
                this.collection.Add("Three");
                this.collection.Add("Four");
                this.collection.Add("Five");
                this.itemsControl.ItemsSource = collection;
            }

            /// <summary>
            /// Handles the MouseLeftButtonDown event of the Button control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
            private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {           
                collection.Remove("Five");
                collection.Insert(1, "--> inserted");
                collection.Add("--> added");
            }
        }

    If you run the project you will see the string collection displayed that is bound to the ItemsCollection control and a button.

    collecitons_screengrab_before

    Pressing the button will remove an item, insert an item at the start and add an item at the end. Notice you do nothing to the UI, all you are doing is manipulating the ObservableCollection that is bound. The result is the UI reflecting the changes in the collection:

    collecitons_screengrab

    Powerful stuff I'm sure you will agree!!

  • Nokia + Silverlight = Mobile RIA

    Nokia have announced they are adopting Silverlight for the S60 on the symbian operating system as well as for Series 40 devices and Nokia Internet tablets. This is great news for the adoption of Silverlight and pushes the possibilities of mobile development forward, and of course kicks off what should be an exciting next few days of Silverlight announcements!!!

  • Develop on Virtual Earth with Intellisense support

    Marc Schweigert has created a great new project on CodePlex that allows you to get JavaScript Intellisense for the Virtual Earth Map Control in Visual Studio 2008.

    He's created a great screen cast here to get you started and the project can be found here.

    Have fun.

  • Joining the world of MSDN Blogs

    So this is my first post so I thought I'd post a brief bio so you can get to know me a little better.

    ab

    I've recently joined Microsoft in the UK as a Consultant in the Delivery Developer team. Day to day you'll find me in the depths of .Net, C# and with a focus on WPF, Silverlight and asp.net building out solutions for our many clients.

    As a general rule of thumb you can expect the content on here to reflect those topics, however I am also interested in general engineering practices and also Internet startups so I may stray off track now and again if I think it's interesting.

    I hope it will be of interest.

    Andy.


© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker