Switch to fluid Switch to wfix Switch to fixed

Brandon Truong

This is Brandon Truong ’s blog.

Default Focus Behavior

Posted by admin on Aug-30-2009

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

I would love to share with you guys about Default Focus Behavior which I just created an hour ago because I thought this behavior would be very handy.

With this behavior, we would be able to set focus to any controls when we trigger any control events.

For example, whenever we click the button, we want to textbox got focused, or when we select the Option 1 for the very first time, the textbox will get focused as below image

defaultfocusbehavior_demo

Click the icon below for the source code

Hopes this helpful :)

http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/digg_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/reddit_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/delicious_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/google_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/myspace_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/facebook_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/twitter_32.png

TextWraping in Silverlight

Posted by admin on Aug-29-2009

Just a little thing I came across when I am trying to set TextWraping property for a TextBox, but the text doesn’t seem to be wrapped. Then I realized if the TextBox is setting with TextWraping greater than 1, the text won’t be wrapped. Just a little thing to keep in mind :)

http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/digg_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/reddit_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/delicious_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/google_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/myspace_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/facebook_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/twitter_32.png

Datagrid Missing Binding Error

Posted by admin on Aug-20-2009

I have run into this silly mistake, and it took me 2 hours to figure it out :(

I am writing it down here for my own reference, and if you ever ran into this problem, hope that this can help you fix your problem quickly.

The problem is I had a datagrid column with the Header but not the Binding, for example

<data:DataGridTextColumn Header=”MyProperty” />

This will cause the below error at runtime

Datagrid Missing Binding Error

To fix it, all I had to do is to put the Binding in it

<data:DataGridTextColumn Header=”MyProperty” Binding={Binding MyProperty} />

Hope this helps

http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/digg_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/reddit_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/delicious_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/google_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/myspace_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/facebook_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/twitter_32.png

UpperCase Behavior

Posted by admin on Aug-17-2009

I was asked to create a TextBox input which has only UpperCase letters. After a bit of research, I have found this article which has inspired me to come up with this solution. As we all know that Behavior is a cool stuff in Silverlight 3, so I decided to use the concept from that article and create a Behavior which detects all the key and uppercase it. Feel free to download the source code and have a play with it.

http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/digg_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/reddit_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/delicious_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/google_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/myspace_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/facebook_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/twitter_32.png

Binding for Converter Parameter

Posted by admin on Jun-12-2009

I have come across the situation where I need to do some Binding for ConverterParameter. Something like

I have done lots of research, and I found out that its impossible to do binding for ConverterParameter.
So I came up with the Solution. I created the Converter but inherited from FrameworkElement

public class ShowDeleteServiceConverter : FrameworkElement, IValueConverter

In the converter class, I created a dependency property

Now, I can do the Binding as usual

And

It might not be the best solution, but it works for me so far. If you have any idea, feel free to drop me comments.

Cheers,

http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/digg_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/reddit_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/delicious_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/google_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/myspace_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/facebook_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/twitter_32.png

How to Change the Startup Class

Posted by admin on Jan-26-2009

Another great tip from Mike Snow.
Read the original article here

When a Silverlight application is launched the entry point is a class that inherits from System.Windows.Application. By default, when you create a new Silverlight application project, this would be your App class which gets defined in App.xaml.cs. You can, however, change which startup class you want to use. In fact, if you do not plan to use XAML at all you can reduce the size of your application by deleting the Page and App classes including the XAML and code behind files.

To accomplish this follow these steps:

Step 1. Create a new Silverlight application project adding a new ASP.net web project to host the Silverlight app.

Step 2. Delete App.xaml and Page.xaml (the CS files will be deleted also).

Step 3. Create a new class and call it StartupTest.cs

Step 4. Modify your new class to inherit from Application as seen here:

public class StartupTest : Application
{
    public StartupTest()
    {
    }
}

Step 5. Right click on your Silverlight application project in the Solution Explorer of VS. From the context menu choose Properties. This will bring up the Properties dialog. Click on the Silverlight tab at the top-left and change the Startup object to be your class as seen circled here:

image

Step 6. Go back to your StartupTest class. Add an event to monitor for when the application has started. You don’t want to do anything until after this event has started.

public class StartupTest : Application
{
    public StartupTest()
    {
        this.Startup += new StartupEventHandler(StartupTest_Startup);
    }
 
 
    void StartupTest_Startup(object sender, StartupEventArgs e)
    {
    }
}

Step 7. The Application.RootVisual is root pointer to the main application UI. You will need to create this object to point an object such as a Grid or Canvas control. Once created, you can add additional controls to the children as you see fit. In the example below, I have created a Canvas as the root and configured its background color to be black, its width to be 800 and height to be 600. Also, I have added a Textbox to the Canvas control.

void StartupTest_Startup(object sender, StartupEventArgs e)
{
    this.RootVisual = new Canvas();
 
    ((Canvas)this.RootVisual).Width = 800;
    ((Canvas)this.RootVisual).Height = 600;
    ((Canvas)this.RootVisual).Background = new SolidColorBrush(Colors.Black);
 
    TextBlock tb = new TextBlock();
    tb.Foreground = new SolidColorBrush(Colors.White);
    tb.FontSize = 20;
    tb.Text = "NO XAML NEEDED!!!";
 
    ((Canvas)this.RootVisual).Children.Add(tb);
}

Step 8. Run the application and you will see the following image rendered in your browser:

image

Technorati Tags:

http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/digg_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/reddit_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/delicious_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/google_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/myspace_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/facebook_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/twitter_32.png

How to Create A Badge Of Your Facebook

Posted by admin on Jan-1-2009

Create a Badge From a Template

  1. Log into your facebook account
  2. Click on the “My Profile” link to view your current profile after you have logged in.
  3. Select the “Create a Profile Badge” link that can be found on your profile.
  4. Choose a template to help create your badge. A photo badge showcases your most recent photo uploads. The Signature Badge has your contact information and is ideal for email and forum signatures. The blog badge is a great addition to your external Web site or blog.
  5. Set the preferences for your template. While they may vary slightly, you must select a layout (Horizontal or Vertical) and a format (Image or JavaScript) for each template.
  6. Finish making changes to your badge and click “Save” to get directions for posting your badge. You will need to copy and paste the provided code into the Web site where you want the badge to appear.

Create a Custom Badge

  1. Show your individuality by choosing to “Create a Badge” from the “Create a Profile Badge” page.
  2. Set the basic layout and format.
  3. Add any items from the drop-down menu that you want to include in your badge. Click the “Add Item” button to add it to your badge. You may add more than one item. With no template, you can add anything you want to your badge. It will preview as you make additions.
  4. Hit the “Save” button to complete your badge and get the necessary code to post it.

Technorati Tags: ,

http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/digg_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/reddit_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/delicious_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/google_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/myspace_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/facebook_32.png http://brandontruong.site90.net/wp-content/plugins/sociofluid/images/twitter_32.png