Lester's WPF\SL Blog


Simple, Easy & Beautiful


 

Blog - Post Feedback Form(CAPTCHA)
  • Lester's WPF\Silverlight Blog

    XAML 2009 Features: Named Object References

    • 0 Comments
    This is part of a series on New WPF\XAML Features In previous releases, if you needed to reference a named object, your XAML would look something like < Label Target =' { Binding ElementName =firstNameBox }' > _Target </ Label > < TextBox Name = 'firstNameBox' > Uses Binding </ TextBox > In the current release (.NET 4), we introduced a built in markup extension x:Reference . This would enable referencing a named object. The above XAML can now be written as < Label Target = ' { x : Reference secondNameBox }'> _Second Target </ Label > Or < Label Target = 'thirdNameBox' > _Third Target </ Label > The references look both forward as well as backwards Another possibility...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Updated File Dialogs

    • 2 Comments
    This is part of a series on New WPF Features In previous releases, WPF open\Save dilogs had the XP style even on Vista. Some workarounds were to use the Vista bridge library or use the winforms dialogs. For this release we fixed this issue. You now get the OS style dialogs :) ... Usage wise its the same, you get the updated behavior for free ... The pic below shows the difference. Share this post
  • Lester's WPF\Silverlight Blog

    XAML 2009 Features: XAML Event handling

    • 0 Comments
    [ This is part of a series on New WPF\XAML Features] In previous releases, when loose XAML had events in it and was loaded it would crash. In V4, there are 2 options to avoid this crash. à On loading events are searched on the root object of the XAML file. Suppose you had the loose XAML like the below < local : MyStackPanel xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns : local ="clr-namespace:DemoApp;assembly=DemoApp"> < Button Click ="Button_Click" > Date (Event on Root) </ Button > As long as the root object (in this case MyStackPanel) can be found, the event will be hooked and will work fine without a crash à The second approach is to define a MarkupExtension that returns...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Cached Composition

    • 7 Comments
    This is part of a series on New WPF Features One of the big improvements in 4.0 is the Cached Composition feature in graphics. This feature enables caching a live UIElement as a bitmap, which enables quick rendering of the element as a bitmap. The UIElement is user interactive and hence will respond to keyboard input, mouse clicks,… Also, transforms, effects,.. which operate on top will not cause the cache to regenerated resulting in better performance. Previously, it was common to use RenderTargetBitmap for this purpose. However, this would be at the cost of interactivity. Lets jump into usage. You have the BitmapCache and the BitmapCacheBrush classes. The former is useful in rendering a complex UIElement while the latter facilitates...
  • Lester's WPF\Silverlight Blog

    XAML 2009 Features: Node Loop flexibility

    • 2 Comments
    [ This is part of a series on New WPF\XAML Features] So by now most of you must have noticed the System.Xaml dll as part of your .NET 4 WPF projects. It’s a well componentized XAML stack that provides a lot of flexibility working with XAML. So at the core we a System.Xaml.XamlReader and XamlWriter which provide the base implementation and definition for a reader and writer. XamlXmlReader is a reader that reads in XAML and produces a XAML node stream. This stream is then consumed by a XamlXmlWriter XamlObjectWriter to produce the object graph. Similarly for the Save path, you have the XamlObjectReader and XamlXmlWriter. So the Load Path looks like XAML à XXR à Node Stream à XOW à Object Graph The Save path would look like...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Full Trust Xbap Deployment

    • 4 Comments
    This is part of a series on New WPF Features In earlier versions, on trying to deploy a Full Trust Xbap, you would get a "Trust Not Granted" error. Its possible to workaround this issue by installing an assembly in the GAC that has the AllowPartiallyTrustedCallersAttribute. Another option is to install a certificate on the user machine and sign the Xbap with the certificate. Yeah, its painful and we worked on this issue for this release Now on deployment, you would get a clickonce dialog so that the user can determine if s\he want to run the Xbap. This is really beneficial in the case of Intranet deployment. Do I hear a WOW.. :) Below is the pictorial difference.. In addition, clicking on the More Information link open up a dialog...
  • Lester's WPF\Silverlight Blog

    Xaml 2009 Features: Built in Types

    • 8 Comments
    In Xaml2009, we have built-in support for common CLR types which simplifies authoring. So rather than specifying something like < s:String xmlns:s ="clr-namespace:System;assembly=mscorlib"> Foo </ s:String > We can use the notation < x:String > Foo </ s:String > The list of types supported is below: • < x:String > • < x:Char > • < x:Single > • < x:Double > • < x:Boolean > • < x:Byte > • < x:Int16 > • < x:Int32 > • < x:Int64 > • < x:Decimal > • < x:Object > • < x:Uri > • < x:TimeSpan > • < x:Array > One thing to note is wrt WPF this will work only in loose Xaml . This means that these...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Bindable Run

    • 0 Comments
    This is part of a series on New WPF Features Bindable run - yeah its possible currently but you would require a custom implementation. if you didnt like to create your own implementation, likely you would be using textblock. Problem here is that its likely you would have issues in copy paste scenarios, layout and what not. Now its a lot easier as the framework supports it. < WrapPanel xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml" > < TextBlock Text ='Hello world!! .NET 4 Coming Soon!! New features in WPF!!' Visibility ='Collapsed' Name ='tbl'></ TextBlock > < FlowDocumentReader Width ="350" BorderBrush ="red" BorderThickness ="3"...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Script Interop in Xbap

    • 1 Comments
    This is part of a series on New WPF Features Often times you have Xbap hosted in a Html page and its pretty common to have some kind of interaction between the host and Xbap. In this release, we have enabled these scenarios. Operation Changes In Code Sample Invoking a function Xbap dynamic script = BrowserInteropHelper .HostScript; script.ReportProgress (progressValue.ToString()); Passing an object to a function Script function ReportDate(dateTime) { date = new Date(dateTime); var dateBox = document.getElementById( "displayDate" ); dateBox.value = date.getFullYear(); } Xbap DateTime date1 = ( DateTime )date.SelectedDate; script...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Binding to Dynamic Objects

    • 0 Comments
    This is part of a series on New WPF Features C# 4.0 allows creation of dynamic objects which is useful when you are interacting with dynamic languages. If you are unfamiliar with the dynamic concept take a quick look at this blog entry So back to WPF. We support binding to dynamic objects.. woohoo... To begin with you need to create the dynamic object (see attached proj ) < Window.Resources > < local : DynamicObjectClass x : Key ="MyDynamicObject" /> </ Window.Resources > < StackPanel Name ="BindPanel" DataContext ="{ StaticResource MyDynamicObject }" > < TextBox Text ="{ Binding Path =A}"/> < TextBlock Text ="{ Binding Path =B.C}" /> < TextBox Text ="{ Binding Path =[(x:Int32...
  • Lester's WPF\Silverlight Blog

    New WPF Features: LayoutRounding

    • 3 Comments
    This is part of a series on New WPF Features LayoutRounding - If you are familiar with Silverlight, this is nothing new. If you are unfamiliar with it, all it does is that it rounds up lengths.. Take for example the code below (hypothetical case) < Border Width ="33.9111111" Height ="80.11111" BorderBrush ="Red" Margin ="2.1222222" BorderThickness ="3.955"> < Border Width ="15.3333333" Height ="40.11111" BorderBrush ="Black" Margin ="2.3333333" BorderThickness ="3.89898555"></ Border > The one on the left is a bit blurry due to the subpixel positioning and doesnt use LayoutRounding. The one on the left is rendered with LayoutRounding and has crisper lines. The property to enable LayoutRounding is UseLayoutRounding...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Key\Gesture Binding

    • 6 Comments
    This is part of a series on New WPF Features We got a lot of feedback to improve the way a developer could set binding to the input keys and modifiers. Earlier, the command property on the inputbinding class was not a Dependency property - so binding to it was out of question. Also it didnt inherit the datacontext of the parent. There are workarounds and most likely you would be doing something like the below as is done in the CoreMVVM libraries. < Window.Resources > <!-- Allows a KeyBinding to be associated with a command defined in the View Model --> < c : CommandReference x : Key ="ExitCommandReference" Command ="{ Binding ExitCommand }" /> </ Window.Resources > < Window.InputBindings > <...
  • Lester's WPF\Silverlight Blog

    New WPF Features: ClearTypeHint

    • 0 Comments
    This is part of a series on New WPF Features WPF enforces grayscale rendering when text is rendered on a transparent area. However, its possible that the background of a control is opaque even though its inside a transparent area. For example, popups have rounded edges and will have the allowstransparency property set. Same is the case with transparent windows. Now in .NET 4, we provide the developer to decide whether to render with cleartype or not. The way to do this is to set the RenderOptions.ClearTypeHint property. RenderOptions.ClearTypeHint ="Enabled" This forces the rendering engine to enable Cleartype for the subtree. Intermediate render targets, such as Effect, OpacityMask, VisualBrush, DrawingBrush, Clip, and Opacity...
  • Lester's WPF\Silverlight Blog

    New WPF Features: CaretBrush\SelectionBrush

    • 4 Comments
    This is part of a series on New WPF Features There have been quite a few asks for changing the selection color and the caret color. We have now provide 2 properties to make this possible CaretBrush SelectionBrush An example usage would be like SelectionBrush ="RED" SelectionOpacity ="0.3" (Default value is 0.6) CaretBrush ="Red " These properties are avaialble on controls that allow selection\caret. Share this post
  • Lester's WPF\Silverlight Blog

    New WPF Features: Custom Speller Dictionary

    • 4 Comments
    This is part of a series on New WPF Features In previous versions, adding a custom dictionary was an unsupported scenario. You could still do it but it required writing a bunch of code. In this release, we have provided suport for adding custom dictionaries. < RichTextBox FontSize ="24" SpellCheck.IsEnabled ="true" > < SpellCheck.CustomDictionaries > < sys:Uri > Dictionary1.lex </ sys:Uri > < sys1:Uri > \\dictServer\Dictionary3.txt </ sys1:Uri > </ SpellCheck.CustomDictionaries > < FlowDocument > < Paragraph > Some Names: Zorig Lester </ Paragraph > < Paragraph > Misspelled: Zorg BlahBlah </ Paragraph > </ FlowDocument > </ RichTextBox...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Jumplists

    • 7 Comments
    This is part of a series on New WPF Features Jumplists is a feature of Win7 where in you can the context menu is richer than the usual close\restore options. WPF provides a managed API to work with these features in Win7. Now that we have seen how it looks like, lets look at how its created [Thanks to Andre for the initial code :) ] Setting up the jumplist is simple and API is really easy for addition\deletion of items JumpList jumpList = new JumpList (); JumpList .SetJumpList( Application .Current, jumpList); JumpTask jumpTask = new JumpTask (); jumpTask.Title = jumpTask.Description = namesToUse[ 0 ]; jumpTask.CustomCategory = "DocumentApps" ; jumpTask.ApplicationPath = "notepad.exe" ; jumpList.JumpItems...
  • Lester's WPF\Silverlight Blog

    New WPF Features: Easing Functions

    • 1 Comments
    This is part of a series on New WPF Features Easing functions enables adding custom math formulas to your animations. The animations also looks more realistic and smoother. WPF now provides this functionality and as in SL there are 11 such inbuilt functions. Each of these come with 2 Easing Modes - EaseIn,EaseOut,EaseInOut. The functions for the EaseIn Mode are shown below. < BackEase Amplitude ='1' EasingMode ='EaseIn' /> < BounceEase Bounces ='3' Bounciness ='2' EasingMode ='EaseIn'/> < CircleEase EasingMode ='EaseIn' /> < CubicEase EasingMode ='EaseIn' /> < ElasticEase EasingMode ='EaseIn' Oscillations ='3' Springiness ='3' /> < ExponentialEase EasingMode ='EaseIn' /> < PowerEase...
  • Lester's WPF\Silverlight Blog

    New WPF Features: TextFormattingMode for clear text

    • 9 Comments
    This is part of a series on New WPF Features Now there has been feedback since 3.0 that the WPF text doesnt render clearly when the fontsizes are smaller. So for .NET 4 we forked on this issue and fixed it by introducind the property TextOptions.TextFormattingMode. The default value is ideal which is what we have currently. The other option is Display and it makes small text look crisper and clear. Lets see it in action < StackPanel xmlns ='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x ='http://schemas.microsoft.com/winfx/2006/xaml'> < TextBox TextOptions.TextFormattingMode ="Ideal" FontSize ="10"> HELLO WORLD </ TextBox > < TextBox TextOptions.TextFormattingMode ="Display" FontSize...
  • Lester's WPF\Silverlight Blog

    VS 2010\.NET 4 Beta2 available for download

    • 0 Comments
    Visual Studio 2010 and .NET Framework 4 Beta 2 will be available to MSDN subscribers, with general availability on October 21. The official launch of Visual Studio 2010 and .NET Framework 4 is March 22, 2010. For info about packaging, pricing, and licensing take a look at the new VisualStudio site Share this post
  • Lester's WPF\Silverlight Blog

    CoreMVVM - now on Codeplex

    After the last post , got quite a few requests to put it on Codeplex. So here it goes : http://coremvvm.codeplex.com/ Share this post
Page 3 of 13 (241 items) 12345»