RSS
 

Archive for the ‘Uncategorized’ Category

Listbox Individual Item Color in Silverlight

12 Jul

This post is mainly a reply on this StackOverflow Question: how to change listbox item’s color individually programmatically in silverlight?

We want to modify the Listbox item template so we get the following layout:

The implementation is fairly simple. We use a converter on our Listbox Item binding and return a Style Property.

The Message Model implementation:

public class Message
    {
        public string Name { get; set; }
        public bool IsInError { get { return String.IsNullOrEmpty(ErrorMessage); } }
        public string ErrorMessage { get; set; }
    }

In the listbox, we will bind these message properties for each item. We can have a different style based on these properties by using the listbox ItemTemplate.
The Listbox Item Template implementation:

        
            
                
                        
                
            
        

For each listbox item, we will assign a style for our TextBlock element.
The Converter implementation:

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if ((bool)value)
            {
                return Application.Current.Resources["ListBoxTextNormalItem"];
            }

            return Application.Current.Resources["ListBoxTextErrorItem"];
        }

The Style implementation:

        

        

You can download the sample source here: ListBoxItemColorSample

 
 

Animate your Silverlight ItemsControl

17 Oct

The idea behind the animation is to inform the users of the new items that were added to the ItemsControl. The new items will fly into the screen from left and right.

Let’s take an existing example from here by Tim Heuer:
Twitter Search Monitor

The ItemsControl in the example consists of a DataTemplate defined in a resource.

Let’s check the following original code snippet from Search.xaml:

            
                
            

If we examine the ItemsControl, we can see that it has a reference to a SearchResultsTemplate Resource. This DataTemplate Resource is defined in the SearchPage. To interact with the items, we need to copy this DataTemplate to a new UserControl.

Now we want to change the reference to the DataTemplate in the Page.Resources to our own UserControl (TwitterItem) in Search.xaml:

 
                
                    
                        
                            
                        
                    
                    
                        
                            
                            
                            
                            
                        
                    
                
            

We can now add some Storyboards to our TwitterItem.xaml:

	

			
				
					
						
					
				
				
					
						
					
				
			
		
		
			
				
				
			
		
	

And we can start the animation in code when our ItemsControl is creating the Items:

public TwitterItem()
        {
            // Required to initialize variables
            InitializeComponent();

            // Global variable to see how many items we already have. Alternate the animation.
            if (((App)App.Current).ItemsCount % 2 == 0)
                FlyLeftToRight.Begin();
            else
                FlyRightToLeft.Begin();
            ((App)App.Current).ItemsCount++;
        }

Here is the final version with some User Interface tweaks. When you search for an item, new items will fade in from left to right and right to left. The application will look up new items each 15 seconds.

TwitterSearchMonitor Animated Source (Visual Studio 2010)

If you’re getting a page not found error, click here to view the application.


Install Microsoft Silverlight


 

Microsoft REMIX 2010 Affligem (Belgium)

13 Oct

REMIX10, September 28th, 2010

Microsoft free event

REMIX Belgium started 3 years ago. It is a free event and if you are interested in microsoft web technologies it’s a great opportunity to pick up some knowledge.
The topics are brought by several microsoft certified speakers.

There are two tracks you can choose from (you can mix session if you want).
- UX Track
- Web developer track

Sessions followed:
Introduction (Luc Van de Velde, Katrien De Graeve)
The introduction was spectacular with demos about Internet Explorer 9 (Beta), Microsoft Kinect and the Windows 7 Phone.

Internet Explorer and HTML5: A Lap Around Windows Internet Explorer 9 For Developers (Pete LePage)
Seems like Microsoft has put a lot of efforts in the new version of Internet Explorer 9. Luckily it’s looking very clean and the performance is as good as other browsers.

UX Super Powers with Expression Blend 4 (Arturo Toledo)
I would really improve my design skills and that’s the reason why I followed an UX Track. Expression Blend is another program that you need to learn. It will take some time before you know every bit, but the session gave a pretty good and brief explanation of what you can do.

Building for the cloud: integrating an application on Windows Azure (Maarten Balliauw)
Developing for the Windows Azure platform is the future. Anyways, if you don’t pay attention, you can pay a lot for the resources used on the platform. Scalability in Windows Azure isn’t built-in but you can easily scale your server loads in code.

Using WebGallery, WebDeploy and IIS Extensions (Luis Alves Martins)
Nice introduction about IIS but as I already know a lot of IIS it wasn’t really useful to me.

Overall it’s a nice event. Some sessions might not be very in depth, but it’s always nice to see new technologies and other people’s work.

 
 

Application manifest generation failed. The out-of-browser settings file was not specified

29 Jul

Error Message: Application manifest generation failed. The out-of-browser settings file was not specified

That error can popup in visual studio if you try to enable the OOB capabilities of silverlight. It has probably to do with Team Foundation Server or reading rights on certain files.

For some reason the *.csproj isn’t updated. You need to manually add the following line:

Under:

Add the following:

Properties\OutOfBrowserSettings.xml

Make sure you can see the OutOfBrowserSettings.xml in your visual studio project under the Properties folder. Otherwise Show all files and include the file in the project.

That should fix it!

 

Running 64 bit virtual machines

30 Mar

If you want to install the latest technologies of Microsoft (like Microsoft Office SharePoint 2010) you will need to have a 64 bit machine to install everything. The problem is that you want to run a guest virtual machine for development on your 64 bit host. Virtual PC does not run any 64-bit machines, so we need to choose an alternative. After some research, I found Virtualbox from Sun.

VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL).

The complete supported list of OS is here:
http://www.virtualbox.org/wiki/VBox_vs_Others

Everything works very smooth and it even seems faster than my current Virtual PC (or is it because I am using the W2k8 R2 now… :) )

 
 

Virtual PC could not connect to the internet

28 Feb

I am pretty excited about my traning class of next week. Architecturing WPF Applications with Brian Noyes from IDesign! While I was setting up my Virtual Machine (Windows Server 2008), I wasn’t able to connect to the internet from my VPC at home. It used to work before at a different location…

My current VPC setting to connect to the internet is setup to use NAT (Shared Networking).

When I looked up my IP Configuration, I had the following result:

The default gateway had been assigned by my VPC and that was probably missing in my Network configuration.

So, basically, you just need to put this setting and everything will work again!

Update:
I found an interesting article about this:
Fix Virtual PC 2007 Shared Networking (NAT) Internet Not Working in Windows Server 2003, 2008 and Vista Guest OS

The problem is that Shared Networking configures the guest operating system to use the same DNS servers as are used by the physical computer. However, when actual DNS query resolving packets are been returned, it’s actually returned from the IP address of “192.168.131.254″, which is the virtual gateway used by Shared Networking (NAT).