Welcome to WindowsClient.net | Sign in | Join

Zuker On Foundations

The realm of .NET (WPF, WCF and all around)

February 2008 - Posts

LINQ to XSD Alpha 0.2

A new version of LINQ to XSD had been released last week.

The new version works with the final release of VS 2008.

"The LINQ to XSD preview illustrates our initial thinking on a strongly-typed programming experience over LINQ to XML. Instead of working with untyped XML trees, LINQ to XSD allows you to program in terms of strongly-typed classes, generated based on an XSD schema."

Follow this link to get the details and download information.

Posted: Feb 25 2008, 09:51 AM by zuker | with no comments
Filed under: ,
Silverlight 2 - First Look

Follow this link to go to Scott Guthrie's post on Silverlight 2

Scott goes through what the upcoming Beta1 release of Silverlight 2 provides with links to a set of tutorials.

Highlights:

  • WPF UI Framework
  • Rich Controls
  • Rich Networking Support
  • Rich Base Class Library

I hope I will get a chance to step into the internals of Silverlight, No doubt it is the future of RIA for Microsoft tech lovers.

Posted: Feb 25 2008, 09:41 AM by zuker | with no comments
Filed under:
WCF 3.5 - Detect Client IP

Following this post.

As said in the post, WCF v3.5 includes easy access to the caller IP.
I can see where I would need this information, it is pretty important in some scenarios that I can think of.

Note that the code will not work 100% of the times.
It depends on the binding you're using and the composition of the message that the client sends.

I guess you could always process the ReplyTo header as part of the WS-Addressing protocol, even in 3.0, but here's another way to go at it.

The service side code to get the client IP:

OperationContext context = OperationContext.Current;

MessageProperties messageProperties = context.IncomingMessageProperties;

RemoteEndpointMessageProperty endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

 

return string.Format("Hello {0}! Your IP address is {1} and your port is {2}", value, endpointProperty.Address, endpointProperty.Port);

Posted: Feb 25 2008, 08:38 AM by zuker | with no comments
Filed under:
Vista SP1 on MSDN Subscriber Downloads

Yippy! Finally, Vista Service Pack 1 is out and ready for us to rush and install.

Mike Ormond's Post

WPF - Selected Item Style

I got around building a decent amount of controls that derived from ListBox.

The default template of a ListBoxItem contains default style for the selection triggered by various triggers.

If you wish to control the colors, you can adjust it by the following:

<ListBox.Resources>
  <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
  <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
</ListBox.Resources>

 If you wish to alter the selection/any other actual behavior:

you can replave the default template of the ListBoxItem and edit anything you like, the following example is a duplicate of the default template with comments on what you should remove if you like to disable selection highlighting.

<ControlTemplate TargetType="{x:Type ListBoxItem}">
  <Border Name="Bd"
               Background="{TemplateBinding Background}"
               BorderBrush="{TemplateBinding BorderBrush}"
               BorderThickness="{TemplateBinding BorderThickness}"
               Padding="{TemplateBinding Padding}"
               SnapsToDevicePixels="true">
    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  </Border>

  <ControlTemplate.Triggers>
    <!--Related to Selection -->
    <Trigger Property="IsSelected"
                 Value="true">
      <Setter TargetName="Bd"
                  Property="Background"
                  Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
      <Setter Property="Foreground"
                  Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
    </Trigger>

    <!--Related to Selection -->
    <MultiTrigger>
      <MultiTrigger.Conditions>
        <Condition Property="IsSelected"
                         Value="true"/>
        <Condition Property="Selector.IsSelectionActive"
                         Value="false"/>
      </MultiTrigger.Conditions>
        <Setter TargetName="Bd"
                    Property="Background"
                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
        <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    </MultiTrigger>
                      
    <Trigger Property="IsEnabled"
                 Value="false">
      <Setter Property="Foreground"
                  Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
    </Trigger>
  </ControlTemplate.Triggers>
</ControlTemplate>

Posted: Feb 20 2008, 08:06 AM by zuker | with no comments
Filed under:
.NET 3.5 Client Product Roadmap

Following Scott Guthrie's post.

Talks about upcoming releases planned for next months.

  • Improved .NET Framework Setup for Client Applications
  • Improved Working Set and Startup Improvements for .NET Client Applications
  • WPF Performance Improvements
  • WPF Control Improvements
  • VS 2008 WPF Designer Improvements

Sweet!

Posted: Feb 20 2008, 08:02 AM by zuker | with no comments
Filed under:
Asynchronous Invocation - Enumerable Extension

I encountered several times in the following scenario:

I have a list of business objects.
My wish is to invoke an action on each of these objects, all of theses actions will be invoked asynchronously using the Thread Pool and it will block until all the asynchronous actions are complete.

I've written a useful extension that makes this scenario very simple to code.

var list = new[] { 1, 2, 3, 4, 5 };
list.WaitAsyncForEach(i => Console.WriteLine("Invoked async for '{0}'", i));

Note - with large enumerables you might consider doing it for a certain batch size at a time, or at least modify the code to enforce a size limitation of some kind.
This is due to the fact that "WaitHandle.WaitAll(waitHandles);" might throw a "NotSupportedException" if the number of objects in waitHandles is greater than the system permits.

A project is attached with the code and the example on how to use it. (Rename to zip)

In order to view the attached files, make sure you enter the specifc post page.

Posted: Feb 17 2008, 09:40 AM by zuker | with no comments
Filed under:
WS-What?

I am upon building a pretty interesting project at work.
I will blog about it as I discover cool and useful things.

I really needed to step into all the WS* specifications and get to know all the protocols out there.
I found a really nice article written by Michele Leroux Bustamante, it's not that new but I find it to be a great step-into the WS* protocols.

Here is the link to the article:
Making Sense of all these Crazy Web Service Standards

Posted: Feb 12 2008, 06:19 PM by zuker | with no comments
Filed under:
Blog Created

I'm glad WindowsClient.net let me join their bloggers group.

 I did have several blogs before, unfortunately I never kept them alive for long.
Hopefully, this stops now :)

This blog will be mainly about WPF & WCF, I will blog about other .NET technologies though. (Silverlight, ASP.NET, ADO.NET Entity Framework, LINQ 2 SQL, etc)

 

Page view counter