ChiaFong

Posts Tagged ‘.NET 3.0’

Slow resizing?

In Programming on 8 October, 2008 at 7:00 pm

Ever feels that the WPF application that you are working on, seems to maximize or resize quite slowly?  If your system is not using a top end graphic card (e.g. on board graphic chip or Nvidia 9300 GS) the likely culprit might be the bitmap effect “dropshadow”.  Since bitmap effect is software rendered, turning on bitmap effect “dropshadow” on a large piece of UI graphic will be quite taxing on the graphic engine, thus resulting in somewhat slow performance when maximizing or resizing.  Turning these off will let you get a instantaneous performance boost.

If you have installed the Windows SDK and choose to install the WPF Performance Suite as well, you can make use of the Perforator which will let you see what part of your WPF app is rendered in software (if you’re using Vista, just do a Instant search for WPFPerf.exe).  If you have some performance issue with WPF application, this tool will be your friend, make full use of it!

Advertisements

Implementing that flat button but get into a clicking problem?

In Programming on 1 October, 2008 at 3:15 pm

Ever try to implement an IE or Firefox kind of flat button (it look like just a image of a toolbar but if the cursor hover over it a square will appear around the image and make it look like a clickable button) in WPF but get into problem because it turn out that clicking the button becomes difficult as you will need to point accurately on the button’s image to activate a hit.  This is most likely because you are using x:Null for the background so that when the mouse cursor is not hovering above the button, the button will appear like a normal image.  Alpha channel to the rescue.  Instead of using “No Brush” (i.e. x:Null), you should actually play with the alpha channel.  Color definition in WPF is more than just RGB, it is actually ARGB with “A” representing the alpha channel.  Think of alpha channel as a opacity value, thus in hexadecimal, FF is full opaque and 00 is totally transparent.  Thus the background of the intended flat button should be declare as #00FFFFFF which is asking WPF to use a transparent color (when A is declare as 00, the value of RGB is actually not that important, as any value there will still mean that the resulted color is a transparent color).  This way even when the mouse cursor is on a transparent background (non-image area), it will still score a hit on the flat button.

To bind or not to bind (Part 2)

In Programming on 25 July, 2008 at 7:00 am

To expand on what I’ve mentioned in my previous post.  The list box declared in XAML will look something like this:

<ListBox
    x:Name="CheckList"
    ItemTemplate="{DynamicResource CheckListTemplate}"
    ItemsSource="{Binding Source={StaticResource CheckedSource},
                  Mode=Default}">
</ListBox>

Under the <Windows.Resources>, the data template will be declared as:

<DataTemplate x:Key="CheckListTemplate">
  <StackPanel Margin="0,3,0,2" Orientation="Horizontal">
    <CheckBox IsChecked="{Binding Path=IsShown}"/>
    <TextBlock Text="{Binding Path=Name}"/>
  </StackPanel>
</DataTemplate>

At the same place or inside a style XAML’s ResourceDictionary, the data source is declared as:

<source:SColorList x:Key="CheckedSource"/>

Inside the C# file the classes are declared as:

    public class SColor : INotifyPropertyChanged
    {
        private string displayName;
        private Color clrShow;
        private bool permanent;
        private bool show;
 
        public bool IsShown
        {
            set
            {
                show = value;
                OnPropertyChanged("IsShown");
            }
            get
            {
                return show;
            }
        }
 
        public string Name
        {
            set
            {
                displayName = value;
                OnPropertyChanged("Name");
            }
            get
            {
                return displayName;
            }
        }
 
        public event PropertyChangedEventHandler 
            PropertyChanged;
 
        private void OnPropertyChanged(String info)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new 
                                PropertyChangedEventArgs(info));
        }
    }
 
    public class SColorList : 
        ObservableCollection<SColor>
    {
 
    }

Under an initialization method, you should then do the following:

        SColorList colorList = 
            (SColorList)FindResource("CheckedSource"); 

After that is done, the binding is complete and you can then add data item into the colorList and it will show up in the list box control.  And the best thing is your designer can do “magic” on the DataTemplate.

Wow! Been a while!

In Programming on 8 December, 2007 at 5:46 am

Yeah, how time flies!  Near the end of the year already.  Visual Studio 2008 has finally been released just 2 or 3 weeks ago.  It is definitely a must for any .NET 3.0 developer to check out VS2008.  With its built-in XAML editor whereby you can finally drag and drop UI controls from the toolbox, this is definitely a big step forward compared to VS2005.

I’ve also developed a VisionBoard program using WPF.  It is a software that let you pin any pictures on to its board like surface.  This is so that you can pin pictures of your goals that you want to achieve and thus remind you of what your goals are.  The installation file is small, but I need to find a way to store those installation file.  So stay tuned!

.NET Framework 3.0 (formerly WinFX) has RTM

In Programming on 7 November, 2006 at 6:31 am

This is really going to be a golden week.  After Microsoft’s latest development platform, .NET Framework 3.0 RTM, tools for developing application that make use of this platform will RTM soon.  Windows Vista arrival will also be imminent.

Release Candidate for Windows SDK and .NET Framework 3.0

In Programming on 2 September, 2006 at 6:00 pm

Hot on the heels of Windows Vista RC1 (or is it the other way around?), Microsoft has released the set of tools that developers can use on Windows Vista RC1 (or use to develop applications that can work on Windows Vista RC1).

The Windows SDK has been updated to be compatible with RC1 of Windows Vista.  Hopefully, all the header files that had been breaking since Windows Vista interim build 5483, has been fixed and applications build using Windows SDK July CTP will not crash on Windows Vista RC1 (they have been crashing on interim build 5536).

The .NET Framework 3.0 has been bump up to Release Candidate status.  Thus any developer that feels more comfortable in Windows XP (hmmm….. that’s a thought) can install this build of .NET Framework 3.0 (together with Windows SDK RC1) and still be able to program applications that can work on Windows Vista RC1.

Strangely, the Visual Studio 2005 extension for .NET Framework 3.0 (codename Orcas) has not been updated to support RC of .NET Framework 3.0.  It has been missing ever since Windows Vista July CTP and .NET Framework 3.0 July CTP.  I hope this will be release soon.

Lastly, designers who wish to get onto the RC1 bandwagon, have to wait patiently.  This is because Microsoft Expression suite of applications has not been release for RC1 just yet.  Soon.  I hope.

Transparency is finally easily enabled in XAML

In Programming on 14 July, 2006 at 3:00 pm

With the release of the June CTP .NET Framework 3.0, transparent background and window with rounded corners can finally be easily tweaked in XAML.  Lauren Lavoie, from Microsoft, blog about how you can go about doing it.  The trick is in Window.AllowsTransparency, just set this property to “True” and then setting the Window.Background to “Transparent” will get you a transparent window.  With the whole background being transparent you can then achieve rounded-corner window by drawing a Border with a CornerRadius defined.  Below is a snippet of the XAML code that Lauren did:

and the result:
Don't forget to check out her blog.

WinFX is now called .Net Framework 3.0

In Programming on 5 July, 2006 at 3:00 pm

A name change that’s all, every other things remain the same.  Its still contains .Net Framework 2.0 (funny isn’t it, a version 3.0 which uses a version 2.0), Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), Windows Workflow Foundation (WWF) and Windows CardSpace (formerly known under a codename as InfoCard).

From the diagram above, you can see that all those components at row 2 and 3 are all part of .Net Framework 2.0 and the first row consist of all the latest developer tools.  .Net Framework 3.0 will also still be shipped together with Windows Vista as well as available for installation under Windows XP and Windows Server 2003.