Locations of visitors to this page
Onteora Software - August 2007

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Silverlight XAML 404 errors

Silverlight XAML 404 errors


I created a simple web application which uses silverlight. Once I was happy with the way it was working I deployed to my webhost. When the web page loaded the silverlight control is not displaying anything.

 

Fidder 2 lets you examine what is going on when a webpage is loading. I see that there is a 404 error when loading the xaml file being displayed in the silverlight control. When I log into my webhost's control panel I see the xaml file is there.

 

According to Tim Heuser's blog all you have to do is Mime type for xaml. I added the mime type for xaml and silverlight control started to work.

 

Mime File .xaml

Type: application/xaml+xml


Hope this helps


kick it on DotNetKicks.com

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Silverlight
Posted by Ken Tucker on Tuesday, August 28, 2007 7:12 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Using Linq for Master Detail in a DataGridView

Using Linq for Master Detail in a DataGridView


I saw in the MSDN forums someone asking how to do a master details relationship with Linq. It is actually pretty simple. Here are the steps involved on creating the relationship. I am using VS 2008 Beta 2 for this example.

  1. Open up Visual Studio 2008 Beta 2 and create a windows forms Application

  2. Add a new Linq 2 Sql classes to the project named Northwind.dbml

  3. Drag the Northwind database's Orders and Order Details table onto the surface

  4. Save the project and build it

  5. Open the data sources window and add a new object data source. Select the orders table

  6. Drag the orders table on your windows form

  7. Drag the orders_details table on the form

  8. In the form load event add this code



VB

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim db As New NorthwindDataContext

OrderBindingSource.DataSource = From o In db.Orders Select o

End Sub

C#

private void Form1_Load(object sender, EventArgs e)

{

NorthwindDataContext db = new NorthwindDataContext();

orderBindingSource.DataSource = from o in db.Orders select o;

}


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: DataGridView | Linq
Posted by Ken Tucker on Saturday, August 18, 2007 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Using XLinq to get a list of Photos from Spaces.Live.com

Using XLinq to get a list of Photos from Spaces.Live.com


Storing photo albums on line is becoming very popular. Spaces.Live.com photo is one place to store albums which exposes its photo albums via an rss feed. I thought it would be nice to test out Visual Studio 2008 XLinq by getting a list of Photo's from the Tampa Code Camp and display them in WPF Listbox.


The photos I am looking for can be found here.

http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/feed.rss

The xml in the rss feed exposes each photo like this

    <item>
      <title>volunteers arrived at 630am - nikita polyakov [mvp] led them</title>
      <link>http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/cns!75364D9E73295107!134</link>
      <description><p><a href="http://thedevfish.spaces.live.com&#47;photos&#47;cns&#33;75364D9E73295107&#33;133&#47;cns&#33;75364D9E73295107&#33;134" mce_href="http://thedevfish.spaces.live.com&#47;photos&#47;cns&#33;75364D9E73295107&#33;133&#47;cns&#33;75364D9E73295107&#33;134"><img src="http://storage.live.com&#47;items&#47;75364D9E73295107&#33;134&#58;thumbnail" mce_src="http://storage.live.com&#47;items&#47;75364D9E73295107&#33;134&#58;thumbnail" border="0"></a></p><p>volunteers arrived at 630am - nikita polyakov &#91;mvp&#93; led them</p><img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8446023494112203015&page=RSS%3a+volunteers+arrived+at+630am+-+nikita+polyakov+%5bmvp%5d+led+them&referrer=" mce_src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8446023494112203015&page=RSS%3a+volunteers+arrived+at+630am+-+nikita+polyakov+%5bmvp%5d+led+them&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;NA=1149&amp;PI=73329&amp;RF=&amp;DI=3919&amp;PS=85545&amp;TP=thedevfish.spaces.live.com&amp;GT1=thedevfish" mce_src="http://c.live.com/c.gif?NC=31263&amp;NA=1149&amp;PI=73329&amp;RF=&amp;DI=3919&amp;PS=85545&amp;TP=thedevfish.spaces.live.com&amp;GT1=thedevfish"></description>
      <comments>http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/</comments>
      <guid isPermaLink="false">cns!75364D9E73295107!134</guid>
      <pubDate>Tue, 24 Jul 2007 18:24:10 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <msn:type>photo</msn:type>
      <live:type>photo</live:type>
      <live:typelabel>Photo</live:typelabel>
      <wfw:commentRss>http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/cns!75364D9E73295107!134/feed.rss</wfw:commentRss>
      <wfw:comment>http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/cns!75364D9E73295107!134</wfw:comment>
      <dcterms:modified>2007-07-24T18:24:10Z</dcterms:modified>
      <enclosure type="image/jpeg" url="http://storage.live.com/items/75364D9E73295107!134" />
    </item>


Lets query the xml feed and get the title for the photo and convert the quid to a link for the photo. The link is http://storage.live.com/items/PictureId. The guid gives us cns!pictureId so we need to replace cns! with http://storage.live.com/items/



Class Window1

    Private Sub Window1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Dim strUrl As String = "http://thedevfish.spaces.live.com/photos/cns!75364D9E73295107!133/feed.rss "
        Dim feeds = XElement.Load(strUrl)

        Dim query = From p In feeds.Element("channel").Elements("item") _
                  Select title = p.Element("title").Value, link = p.Element("guid").Value.ToString.Replace("cns!", "http://storage.live.com/items/")

        lstPhotos.ItemsSource = query.ToList
    End Sub
End Class

Pages XAML

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:CodeCampPhotos"
    Title="Window1" Height="300" Width="300">
    <Grid>
<DockPanel>
<ListBox Name="lstPhotos" DockPanel.Dock="Top">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=title}" FontSize="10" />
<Image Source="{Binding Path = link}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</Grid>
</Window>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Asp | Linq
Posted by Ken Tucker on Thursday, August 09, 2007 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Binding to a WPF Listbox Part 2

Binding to a WPF Listbox Part 2


In this example we will group the data in the WPF Listbox with CollectionView class.   We will add a GroupStyle which will allow us to expand or hide the grouped data.  We will start off by making a List which contains an Animals class.  Then we create a ListCollectionView from the list.  Finally we create an CollectionView from the ListCollectionView and add a GroupDescription to it.  Then we bind the ListBox to the CollectionView



Pages XAML

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
 <Window.Resources>
  <DataTemplate x:Key ="lstItem" >
   <StackPanel>
     <TextBlock Text="{Binding Path=Animal}"/>
   </StackPanel>
  </DataTemplate>

 </Window.Resources>
  <Grid>
  <ListBox Margin="14,15,47,34" Name="ListBox1" ItemTemplate="{StaticResource lstItem}" >
   <ListBox.GroupStyle>
    <GroupStyle>
     <GroupStyle.ContainerStyle>
      <Style TargetType="{x:Type GroupItem}">
       <Setter Property="Margin" Value="0,0,0,5"/>
       <Setter Property="Template">
        <Setter.Value>
         <ControlTemplate TargetType="{x:Type GroupItem}">
          <Expander IsExpanded="True" BorderBrush="#FFA4B97F"
                          BorderThickness="0,0,0,1">
           <Expander.Header>
            <DockPanel>
             <TextBlock FontWeight="Bold" Text="{Binding Path=Name}"
                                 Margin="5,0,0,0" Width="100"/>
             <TextBlock FontWeight="Bold"
                                 Text="{Binding Path=ItemCount}"/>
            </DockPanel>
           </Expander.Header>
           <Expander.Content>
            <ItemsPresenter />
           </Expander.Content>
          </Expander>
         </ControlTemplate>
        </Setter.Value>
       </Setter>
      </Style>
     </GroupStyle.ContainerStyle>
    </GroupStyle>
   </ListBox.GroupStyle>
  </ListBox>
 </Grid>
</Window>

 

The Code

Class Window1

    Private Sub Window1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Dim lst As New List(Of Animals)
        lst.Add(New Animals("Dog", "Mammal"))
        lst.Add(New Animals("Parrot", "Bird"))
        lst.Add(New Animals("Swordtail", "Fish"))
        lst.Add(New Animals("Cat", "Mammal"))
        lst.Add(New Animals("Falcon", "Bird"))
        lst.Add(New Animals("Molly", "Fish"))
        lst.Add(New Animals("Guppy", "Fish"))
        lst.Add(New Animals("ferret", "Mammal"))
        lst.Add(New Animals("Eagle", "Bird"))

        Dim lcv As New ListCollectionView(lst)

        Dim col As CollectionView
        col = CollectionViewSource.GetDefaultView(lcv)
        Dim groupDescription As PropertyGroupDescription = New PropertyGroupDescription
        groupDescription.PropertyName = "Species"

        col.GroupDescriptions.Add(groupDescription)
        ListBox1.ItemsSource = col
    End Sub
End Class

Public Class Animals
    Private mstr_Animal As String
    Public Property Animal() As String
        Get
            Return mstr_Animal
        End Get
        Set(ByVal value As String)
            mstr_Animal = value
        End Set
    End Property


    Private mstr_Species As String
    Public Property Species() As String
        Get
            Return mstr_Species
        End Get
        Set(ByVal value As String)
            mstr_Species = value
        End Set
    End Property

    Public Sub New(ByVal Anml As String, ByVal spc As String)
        mstr_Animal = Anml
        mstr_Species = spc
    End Sub
End Class

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: WPF
Posted by Ken Tucker on Monday, August 06, 2007 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Binding to a WPF Listbox Part 1

Binding to a WPF Listbox Part 1


Binding to a WPF Listbox is a lot more flexible than binding to a Windows Form listbox.  In the WPF Listbox you need to define a DataTemplate which tells the Listbox how to display the data.  For this example we will create an Animals class and display the data in a Listbox.



Pages XAML

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
 <Window.Resources>
  <DataTemplate x:Key ="lstItem" >
   <StackPanel>
    <Grid>
     <Grid.ColumnDefinitions>
      <ColumnDefinition Width="75" />
      <ColumnDefinition Width="75" />
     </Grid.ColumnDefinitions>
     <TextBlock Text="{Binding Path=Animal}" Grid.Column="0" />
     <TextBlock Text="{Binding Path=Species}" Grid.Column="1" />
    </Grid>
   </StackPanel>
  </DataTemplate>

 </Window.Resources>
  <Grid>
  <ListBox Margin="14,15,47,34" Name="ListBox1" ItemTemplate="{StaticResource lstItem}" >
  </ListBox>
 </Grid>
</Window>

The Code

 

Class Window1

    Private Sub Window1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Dim lst As New List(Of Animals)
        lst.Add(New Animals("Dog", "Mammal"))
        lst.Add(New Animals("Parrot", "Bird"))
        lst.Add(New Animals("Swordtail", "Fish"))
        lst.Add(New Animals("Cat", "Mammal"))
        lst.Add(New Animals("Falcon", "Bird"))
        lst.Add(New Animals("Molly", "Fish"))
        lst.Add(New Animals("Guppy", "Fish"))
        lst.Add(New Animals("ferret", "Mammal"))
        lst.Add(New Animals("Eagle", "Bird"))


        ListBox1.ItemsSource = lst
    End Sub
End Class

Public Class Animals
    Private mstr_Animal As String
    Public Property Animal() As String
        Get
            Return mstr_Animal
        End Get
        Set(ByVal value As String)
            mstr_Animal = value
        End Set
    End Property


    Private mstr_Species As String
    Public Property Species() As String
        Get
            Return mstr_Species
        End Get
        Set(ByVal value As String)
            mstr_Species = value
        End Set
    End Property

    Public Sub New(ByVal Anml As String, ByVal spc As String)
        mstr_Animal = Anml
        mstr_Species = spc
    End Sub
End Class

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: WPF
Posted by Ken Tucker on Monday, August 06, 2007 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed