Feed on
Posts
Comments

When you use a XAML element like <Button> in your Silverlight application you get an instance of the System.Windows.Controls.Button class.  Namespace mapping is what links the XAML namespace “xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation” in your XAML file with the real .NET namespaces that contain the .NET types.    This mapping is accomplished via the XmlnsDefinitionAttribute class.  At some point in the Silverlight development cycle a programmer at Microsoft decorated the System.Windows assembly with the XmlnsDefinitionAttribute.  Because of that mapping you have access to over a dozen .NET namepaces in your XAML file.

Mapping

Here’s an example from System.Windows.dll

[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Data")]

Setting this mapping allows all the public classes in  the System.Windows.Data namespace within the System.Windows.dll  to be access in XAML. 

System.Windows.Data is not the only mapping however.  .NET Reflector is a handy tool to learn which .NET assemblies use the XmlnsDefinition attribute and to learn more about mapping details.

Exploring with Reflector

Start by opening .NET Reflector and loading the Silverlight assemblies.

image

Click the Add button to create a new list of assemblies.  I’ve named mine ‘Silverlight’.

image

The next screen is where you choose from the installed frameworks.  Here, I picked Silverlight 3.0.xxx.xxx.

image

That’s all, now you are ready to start exploring the Silverlight assemblies.

Search for XmlnsDefinition

Pressing F3 brings up search window.  Type in XmlnsDefinition and the class will appear in the results window.

image

Double click the XmlnsDefinition result to see the class in the main treeview.

image

Next, with XmlnsDefinition selected in the treeview press Ctrl-R to bring up the Analyzer window.  The Analyzer can determine which assemblies are using this attribute.  Expand the Used By node.   As you can see there is only one assembly that has the XmlnsDefinition attribute applied.

image

Just for contrast, and to show that WPF and Silverlight are different, here is a screenshot of the WPF assemblies that are using the XmlnsDefinition attribute.

image

Examine the details

It’s time to inspect the metadata inside the System.Windows.dll.   With System.Windows selected in the Analyzer, press the Spacebar.  This will select the System.Windows node in the treeview.  Press the Spacebar a second time to show the Disassember details.  Choose your preferred language in the dropdown.  I’m using C# for the next screenshots.

image

The Disassember  window shows all the attributes applied to the System.Windows assembly.    There are two batches of XmlnsDefinition attributes.  The first batch is using the “http://schemas.microsoft.com/client/2007" URI.  This URI is a holdover from the Siverlight 1 days.   It’s still there, for legacy reasons.  The next batch,  is using the “http://schemas.microsoft.com/winfx/2006/xaml/presentation" URI.  This is the default URI you see in all Silverlight 3 applications.

image

I count 14 namespaces that are affiliated  with the “http://schemas.microsoft.com/winfx/2006/xaml/presentation" and one that’s affiliated with “http://schemas.microsoft.com/winfx/2006/xaml”

At PDC 2009 recently, we heard that the Silverlight 4 beta release is available for download. This tip gives a quick overview of the new features.

From a modest start less than three years ago, Silverlight has grown into a serious competitor in the rich Internet client space. Currently it is installed on 45% percent of all internet connected devices. In some areas of the world, most notably Europe, the number climbs to 60%. For another important indicator in the growing influence of Silverlight just look around the Internet and tally up the companies betting on this new technology; over 350 partners in all. These companies are placing a strategic bet on Silverlight for several reasons, including:

  • One, Microsoft is a dominant player in many technologies and it seems likely that the Silverlight platform will be a success.
  • Two, Silverlight is similar to other Microsoft frameworks, like WPF, and is programmed in familiar Microsoft languages like Visual Basic and C#.
  • Three, Silverlight is filled with compelling feature that simplifies building modern graphic rich applications. With Silverlight 4 these features get even better.

To get started you’ll need to download and install the following:

  • Visual Studio 2010 Beta 2
  • Silverlight Tools for Visual Studio 2010
  • Expression Blend for .NET 4 Preview

Silverlight 4 is bursting with enhancements and new features. Here’s are some of the highlights.

New CLR
Silverlight 4 now includes the soon to be released.NET 4 runtime. This means new features like support for Dynamic objects.

Printing
Silverlight 1 shipped with no print support. Immediately Microsoft was flooded with requests to add this feature. It took a few releases but Microsoft finally has a printing API in Silverlight.

public void SampleCode()
{
 var doc = new PrintDocument();
 doc.DocumentName = "Printing the Grid";

 // wire up event which will print UI
 docToPrint.PrintPage += PrintUi;

 docToPrint.Print();
}
public void PrintUi(object s, EventArgs e)
{
 e.PageVisual = this.MainGrid;
}

Better controls

The included control count keeps rising– here are a few of the new controls.

BusyIndicator: A simple ‘waiting’ screen that informs users of a pending task.

RichTextArea: Embed complex text, image and lists in your Silverlight application. Note that this is a separate control from the WebBrowser control, which permits usage of HTML.

Charting: Though Microsoft’s chart offering is not as complete as the third party vendor chart packages their charts handle the most common data visualization needs.

Accordion: A collection of collapsible areas.

LayoutTransformer: Applies a transform to its embedded content.

Rating: Displays a rating picker which is customizable with your own images.

Time Picker: Allows the user to select a time from a dropdown.

New Themes: 11 new themes are available for sprucing up your control set.

Bi-Directional Support: Silverlight controls now support bi-directional text and left-to-right layout.

Languages: Thirty new languages are now supported, including Thai, Hebrew and Arabic.

Other improvements

  • Silverlight now loads applications quicker than Silverlight 3 and improves runtime performance by up to 200%.
  • Cut and paste now work as expected in most client side applications.
  • Drag and drop is now available, allowing users to drag content into the Silverlight application.
  • Mouse interaction is better with right click events and mouse scrolling capabilities added.
  • If the user’s monitor is multi-touch aware you can capture the multi-touch input in your Silverlight application.
  • Deep Zoom now uses hardware acceleration, which results in faster animation and support for larger datasets. For an interesting use of Deep Zoom and Photo Synth see Microsoft Pivot; a new data visualization system that works with huge datasets.
  • Google Chrome browser support.

In addition to the Silverlight bits, there are beta releases available for related tools like WCF RIA Services, Visual Studio 2010, Silverlight Toolkit and Expression Blend 4. So, there’s a lot for us Silverlight users to explore.

[Original article on TechTarget.com]

Application developers are constantly pushing the boundaries between Web applications and client applications. Why?  Because want our Web apps to work more like client apps and vice versa. But Web application developers must face the security implications inherent in the Web deployed model. The big question, how much trust should be granted to an Internet application?

Silverlight is a great case in point. Imagine that your Silverlight application requires access to the user’s webcam or you wish to write files into the My Music folder. Silverlight is a Web technology, or at least is deployed via a browser. To mitigate security concerns, Silverlight is constrained to run in a sandbox. This sandbox restricts what the Silverlight application can do to the local computer. This is sensible as administrators need assurance that Silverlight applications won’t commandeer the system. But this also means that sandboxed applications are walled off from accessing local devices, like hard drives and webcams for example.

Types of Out Of Browser applications
Silverlight 3 blurred the line between online and offline applications by enabling the Out Of Browser (OOB) setting. In version 3 you can take your application out of browser which permits the user to enjoy your application while disconnected from the network. Version 4 ramps up the features available to OOB applications.

Living in the sandbox

HTML Hosting: It’s now possible to include embedded HTML within your Silverlight application. Use the new WebBrowser control as follows:

<WebBrowser x:Name="bannerAdControl" Width="300" Height="200" />
<!--  add html to webbrowser control -->
bannerAdControl.NavigateToString("<h1>Download Silverlight now.</h1>");

Under the hood the WebBrowser control uses WebKit on the Mac and the IE browser control on Windows.

OOB Window settings: Silverlight 4 offers full control over window settings such as start position and size.

Popup Notifications: You’re probably familiar with the animated ‘toast’ window that is used by Windows application to provide real-time notifications from email clients. Here’s how to launch a notification from an OOB application.

var nw = new NotificationWindow();
nw.Width = nw.Height = 300;

var cn = new CustomNotificationWindow();
cn.Header ="New Mail";
cn.Text ="You have new mail!";
. . .
nw.Contents = cn;
nw.Show(3400);

Requesting elevated privileges

Silverlight 4 has a number of new features that need elevated privileges. For security reason this can only be granted if the user consents to an elevation request. To ask for permission to use the webcam, use the CaptureDeviceConfiguration.RequestDeviceAccess( ) method. Make this call and you will the following dialog.

Once the user has granted permission you can grab the video stream with a few lines of code.

CaptureSource cs;

var device = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
if (null != device)
{
   cs = new CaptureSource();
   cs.VideoCaptureDevice device vcd;
   cs.Start();

   var brush = new VideoBrush();
   brush.Stretch = Stretch.Uniform;
   brush.SetSource(cs);
       rect.Fill = videoBrush;
}

Trusted applications

Additional features are available to OOB applications which are granted trust from the user. Simply set the "Require elevated trust…" checkbox in the Visual Studio 2010 properties settings. Yes, Silverlight has a group policy which administrators can use to manage which applications or domains are trusted.

The user will see the following dialog box when converting a Silverlight application to an OOP application.

Now that you have full trust, here is a partial list of the new Silverlight 4 privileges.

  • Full Screen Keyboard Access: To prevent spoofing attacks Silverlight 3 disables most keyboard events while in full screen mode. In Silverlight 4 this restriction has been lifted for trusted OOB applications.
  • File Access: Read and write to the more areas of the hard drive including My Music, My Document etc. on Windows OS and similar location on the Mac.
  • COM automation: Permits access to COM automation servers like Microsoft Excel, USB security card readers and other devices.
  • Network Cross Domain: Networking restrictions on HTTP access are dropped for trusted OOB applications. Grab resources from any domain without needing a cross-domain policy file in place.

[Original article on TechTarget.com]

It’s easy to forget about animated GiF’s now-a-days, what with the new tools available in Flash, Siverlight, WPF and other graphic friendly frameworks.

I’m not sure what tool DVDP used to create these GIFs, but I like watching them.

 

 

See more of DVDP’s work at http://dvdp.tumblr.com/tagged/dvdp%20done

This question crops up from time to time. “Why is my Silverlight Usercontrol background always White?”.

Take this simple example.

<UserControl x:Class="Blog.WpfWonderland.MainPage"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         Background='Orange'>
    <Grid x:Name="LayoutRoot">

    </Grid>
</UserControl>

Run this example and you get a white page.  To be more precise you will get a page that is the color specified in the host page.   Change the color of the background in the host page object tag as shown below and you will see a green page.  Still no orange colored UserControl.

<object data="data:application/x-silverlight-2," 
        type="application/x-silverlight-2"
        width="100%" height="100%">
        <param name="background" value="green" />

The solution is simple as seen below.

<!– The solution.

   Assign the background brush to a top level
    Panel that is set to
   be the same size as the parent UserControl-->
<Grid x:Name="LayoutRoot"
      Background='Orange'>
       <!-- put the rest of your UI in another panel -->
    <Grid Width='200'
                Height='300' 
Background='Yellow'>

    </Grid>
    </Grid>

image

The last couple years have seen a dramatic increase in the fidelity of fluid/particle systems.  Here is an superb example of the usage of a particle system in a video.  Created by deKO.lt

SPA from DeKo on Vimeo.

Biggest challenge was to create characters in those fluids/smoke and clouds. So first, in 3dsmax simple low poly characters was modeled. Those meshes was animated and used as a proxy objects for fumefx fluids simulations, then using pflow I’ve placed particles on fluids motion data. Every character had millions of particles, which was rendered in Krakatoa. After 2 months of working and rendering every shot, I’ve started to compositing all rendered layers. This part took me another month and after we got final soundtrack from compositor, all works was done. Happy days :)

Do you have a WPF shader effect that you are proud of?  Do you want to bask in the adulation of your peers?  Or do you just want to show off your HLSL prowess?

silhouetteChampion

Your shader could be part of the ShaderGallery, the free Expression Blend effects add-in.

 

Send me a copy of your shaders (fx files please) and the best ones will become part of  the next wave of effects in ShaderGallery.

One of the neatest additions to Expression Blend 3 is the Effects pane.  You’ll find it in the Asset panel.

image

This makes it dead simple to add an effect to an item on the Blend Artboard.  Just drag the effect onto the desired item and you get an instant effect.

image

The effect is easy to configure, as Blend provides a panel on the Properties pane.

image

What the problem then?

Unfortunately Blend only ships with two shader effects; BlurEffect and DropShadowEffect.  If you want any other shader you have to write your own. The good news is that WPF exposes a ShaderEffect base class that you can use.  The bad news is you have to learn another programming language, HLSL, and use it to write the DirectX shader code. If you are a developer it’s not that hard to create your own effects but it is definitely not something a designer is going to want to tackle.

As most of my regular readers know I’ve written a tool (Shazzam) to make it simple to create and test shaders.  Over the last year I’ve collected a library of shaders, most of them from Microsoft, that I include as samples in Shazzam.

Announcing ShaderGallery

I thought it would be a good idea to add these shaders to Expression Blend.  I talked to a few of my WPF Disciple buddies, they thought it was a great idea too.  I pinged Adam Kinney and a couple of Microsoft friends and asked them if they knew of anyone developing a Blend effects library.  Adam said, “No, I don’t know of any but would love to have one.” 

So in the end I decided to create ShaderGallery.  It is a free add-in for Expression Blend that contains ~25 effects. 

image

 

Shipping Date

The goal is to have the application done by opening day at PDC09 (November 17th).   The shaders are done.  All that’s left to do on the project is get the designer interaction code finished, so that Expression Blend works correctly when editing the shader properties.

Here’s a list of the Expression Blend specific talks next week at PDC 09. 

SketchFlow: Prototyping to the Rescue

See how SketchFlow lets designers and developers create, distribute, review and evolve compelling, rich prototypes cost-effectively and easily. Learn how SketchFlow can help you improve your designs through rapid prototyping, and how you can extend and adapt SketchFlow to meet the needs of your projects and environments.

Microsoft Expression Blend 3 for Developers: Tips, Tricks and Best Practices

Hear how developers can leverage Expression Blend to rapidly create sophisticated and compelling Silverlight and WPF applications. See what a difference adding animation, transitions and interactivity can make in traditional line of business applications. Also learn how to leverage advanced data-binding techniques and also make your applications match your organization’s style guidelines.

Here’s a list of the Windows 7 and DirectX specific talks next week at PDC 09. 

Windows 7 and Graphics

Windows Touch Deep Dive

Windows provides applications a default experience for gestures and touch interaction. Applications that want to go beyond that basic experience have a powerful platform to build on top of. This session is targeted at developers interested in building touch-optimized experiences. We look closely at some of the more powerful portions of the Touch platform, like manipulation and inertia processors, as well as cover real-world problems that developers have encountered and overcome. Come help build the next generation of user experiences!

Windows Ribbon Technical Deep Dive

This talk covers some of the more subtle and complex aspects of designing and implementing a ribbon. Explore how to build a great gallery (a critical task for any ribbon), how to make use of contextual tabs and application modes, etc. We draw from specific experiences gained by the Windows Live team, by examining some lessons learned from these early Windows Ribbon adopters.

Modern 3D Graphics Using Windows 7 and Direct3D 11 Hardware

Dig deep into the capabilities of Direct3D and Windows 7. With the onset of new Direct3D 11 hardware, gain practical knowledge to help you push graphics to the limit. Learn about the new tessellation stage in Direct3D 11, which enables an unprecedented level of rendering quality by dynamically generating geometry on the GPU. In addition, see how the multi-core improvements in the Direct3D 11 runtime can help you scale your application to take full advantage of all of the cores on a machine. Finally, take a peek at using the power of DirectCompute (the hardware accelerated general purpose computing technology) in a graphics application context.

Developing with the Windows API Code Pack for Microsoft .NET Framework

The Windows API Code Pack for Microsoft .NET Framework provides a source code library that can be used to access some new Windows 7 features (and some existing features of older versions of Windows operating system) from managed code. These Windows features are not available to developers today in the .NET Framework. This session will show you how to access features like taskbar integration, jumplists, libraries, sensor platform, Direct2D, and more.

Building Sensor- and Location-Aware Applications with Windows 7 and .Net Framework 4

How many times have you thought to yourself, “My application would be so much better if it knew where the user was?” With Windows 7 and the .NET Framework 4.0, you now have the tools at your fingertips to location-enable your applications. Based on the new Location platform for Windows 7, the location API in .NET Framework 4.0 provides a single, consistent API to get you your latitude and longitude regardless of the underlying technology that acquired it—allowing you to focus on creating exciting, differentiated location-aware applications.

Advanced Graphics Functionality Using DirectX

The number of PC configurations is exploding. With the onset of netbooks as well as high-end desktop systems using the latest in graphics hardware, creating an application that can target all of these systems is getting harder every year. Join us as we explore the many options available in Windows 7 to facilitate graphics development across all different hardware configurations, from low-end integrated to top of the line discrete GPUs. Learn about Direct3D 10 Level 9, which enables Direct3D 10 applications to run on pretty much every computer in the market today. Check out WARP, our new software rasterizer that lets your application use high-quality graphics even when there’s no graphics card. Finally, learn about Direct2D, DirectWrite and WIC, and the interoperability of Windows 7 technologies for making slick, high-quality graphics for your applications of the future.

DirectX11 DirectCompute

DirectX 11 introduces DirectCompute as a way to access the computational capability of the GPU in a more flexible way. It opens the door to operations on more general data-structures beyond just arrays, and to new classes of algorithms as well. This talk covers the key features of DirectCompute’s compute shader, and how they can be used by developers in their applications. These features include: explicit thread dispatch, communication of data between threads, and a rich set of primitives for random access and streaming I/O operations. These features enable faster and simpler implementations of techniques already in use on the CPU.

Older Posts »