Silverlight 2.0 Cross Domain Calls

I was just reading Scott Guthries blog post about silverlight 2.0 and I came across a section discussing how Silverlight will be able to do cross domain calls. I have been very curious how they were planning on solving this one without risking the security of silverlight.

It turns out that all you need on the remote domain is an XML policy file that will allow applications to call your domain directly. It seems that this is how flash has been doing it for a while now and silverlight 2.0 will also respect flash policy files.

Flash vs. Silverlight, Indeed

I was just looking at indeed.com and decided to put in Flash vs. Silverlight. The results are pretty interesting:

At the time of this posting flash goes from 0% in May ’05 to about 100% in Sept ’07 while silverlight has gone from 0 at May ’07 to 1,300% in Oct. ’07. I guess we can see that Microsoft has done a good job of getting people excited about Silverlight. Now all they need to do is devliver the goods.

Also, one other interesting thing is how F# creates a graph that sort of looks like the New York skyline:

That seems pretty ironic from a functional language.

Dynamic Templated TreeViewItem in WPF

I struggled with this for a long time for some reason so I decided to post a simple example here for everyone who may be encountering the same thing. The scenario I have here is when you have a treeview with several hardcoded treeview items and at the lowest levels of leafs you have them bound to some data provider. The trick is trying to dynamically bind the treeview items to different data templates based on some criteria.

The real example was to have a label and a text box for the dynamic items based on whether you are trying to edit it or not. The trick turned out to be to wrap your DataTemplate in a control and use styling to dynamically switch it.

 Download Sample Project

<Window

 x:Class=”DynamicTemplatedTreeViewItem.Window1″

 xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;

 xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;

 Title=”Window1″

 Height=”300″

 Width=”551″>

 <Window.Resources>

  <ResourceDictionary>

   <ControlTemplate x:Key=”SelectedTemplate” TargetType=”{x:Type Control}”>

    <Label Content=”{Binding XPath=title}” Foreground=”Red” FontWeight=”Bold”  />

   </ControlTemplate>

   <ControlTemplate x:Key=”DefaultTemplate” TargetType=”{x:Type Control}”>

    <Label Content=”{Binding XPath=title}” />

   </ControlTemplate>

   <DataTemplate x:Key=”template”>

    <Control Focusable=”False”>

     <Control.Style>

      <Style TargetType=”{x:Type Control}”>

       <Setter Property=”Template” Value=”{StaticResource DefaultTemplate}” />                           

        <Style.Triggers>

         <Trigger Property=”IsMouseOver” Value=”True”>

          <Setter Property=”Template” Value=”{StaticResource SelectedTemplate}” />

         </Trigger>

        </Style.Triggers>

       </Style>

      </Control.Style>

     </Control>

    </DataTemplate>

    <XmlDataProvider x:Key=”justnbusiness” Source=”http://www.justnbusiness.com/feed.aspx&#8221; />           

   </ResourceDictionary>

  </Window.Resources>

  <Grid>

  <Grid.ColumnDefinitions>

   <ColumnDefinition/>

   <ColumnDefinition/>

  </Grid.ColumnDefinitions>

  <TreeView

   HorizontalAlignment=”Stretch”

   x:Name=”treeView”

   SelectedValuePath=”description”

   BorderBrush=”#00000000″

   Background=”#00000000″>

   <TreeViewItem

    ItemsSource=”{Binding

     Mode=Default,

     Source={StaticResource justnbusiness},

     XPath=/rss/channel/item}”

    ItemTemplate=”{StaticResource template}”

    Header=”Blog Posts”/>

   </TreeView>

   <Border

    Grid.Column=”1″

    CornerRadius=”5,5,5,5″

    BorderThickness=”1,1,1,1″

    BorderBrush=”#FF000000″

    Padding=”5,5,5,5″

    Margin=”20,20,20,20″>

   <TextBlock

    Text=”{Binding

     Path=SelectedValue,

     ElementName=treeView,

     Mode=Default}”

     TextWrapping=”Wrap”/>

  </Border>

 </Grid>

</Window>

 

Twin Cities Code Camp Spring 2008

I will be giving another talk at the next Twin Cities Code Camp about Visual Studio integration. The event is on April 5th and is free so you should definitely come down and make me sweat with questions that I cannot answer!

http://www.twincitiescodecamp.com/

I plan on talking about visual studio integration in general but I will hopefully show off the current state of the NBusiness 3 plugin as well.