Alessandro Del Sole's Blog

/* A programming space about Microsoft® .NET® */
posts - 159, comments - 0, trackbacks - 0

My Links

News

Your host

This is me! This space is about Microsoft® .NET® and Microsoft® Visual Basic development. Enjoy! :-)

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.

Microsoft MVP

My MVP Profile

I'm a VB!

Watch my interview in Seattle

My new book on VB 2015!

Pre-order VB 2015 Unleashed Pre-order my new book "Visual Basic 2015 Unleashed". Click for more info!

My new book on LightSwitch!

Visual Studio LightSwitch Unleashed My book "Visual Studio LightSwitch Unleashed" is available. Click the cover!

Your visits

Follow me on Twitter!

CodePlex download Download my open-source projects from CodePlex!

Article Categories

Archives

Post Categories

.NET Framework

Blogroll

Help Authoring

Microsoft & MSDN

Setup & Deployment

Visual Basic 2005/2008/2010

gennaio 2009 Blog Posts

WPF: Styling controls at runtime in Visual Basic code

In WPF applications we usually assign styles or control templates to user controls in XAML code. This is the typical situation when you have a predefined number of controls in the user interface. But sometimes there are situations where you will need to instantiate user controls at runtime in Visual Basic code so you could also need to assign styles at runtime.   Let’s make a simple but practical example. Suppose you have a simple style that you declared inside the window’s resources:       <Window.Resources>         <Style x:Key="myStyle" TargetType="Button">             <Setter Property="Width" Value="100"/>             <Setter Property="Height" Value="30"/>             <Setter Property="Margin"...

posted @ mercoledì 21 gennaio 2009 18:17 | Feedback (0) | Filed Under [ Visual Basic Windows Presentation Foundation ]

Master-details forms with the ADO.NET Entity Framework

If you are a little bit familiar with LINQ to SQL, you probably already know how simple is creating a basic Windows Forms application for exposing one-to-many relationships between entities via master-detail representations through the UI.   In LINQ to SQL this can be accomplished using the Microsoft Visual Studio 2008 automation engine that allow dragging and dropping objects (entities) from the Data Sources window onto the target form. The IDE then adds the needed UI controls, manages the data-binding leaving to us the only job to specify in code the data source regarding the “one” part in the relationship.   Unfortunatley...

posted @ martedì 20 gennaio 2009 13:02 | Feedback (0) | Filed Under [ Visual Basic LINQ/EF/OData ]

Strongly typed eager loading in Entity Framework with Visual Basic

In a previous post we discussed about creating data forms for showing master-details data representations with Visual Basic 2008 and the ADO.NET Entity Framework and we said that using strings within the eager loading technique could cause the loss of the benefits provided by the LINQ strongly typed approach.   I then found a blog post by Matthieu Mezil (Microsoft Visual C# MVP), who solved the problem implementing a custom Include method using lambda expressions instead of strings, taking the advantage of the strongly typed approach. Matthieu's code is in Visual C# with his help we converted the code into Visual Basic...

posted @ lunedì 19 gennaio 2009 23:59 | Feedback (0) | Filed Under [ Visual Basic LINQ/EF/OData ]

WPF and the Handles keyword

When developing WPF applications with Visual Basic 2008 you may encounter a particular problem due to the bad usage of the Handles clause in events handling. In other words, if you assign an event handler to an user control in XAML code and then you specify an Handles clause for the same user control when writing the event handler, the event is handled twice and the consequences can be dangerous. For example, let's consider the following XAML code which just declares a button:         <Button Width="100" Height="30" Name="Button1" Click="Button1_Click" /> As you can see, I assigned an event handler to the control....

posted @ giovedì 15 gennaio 2009 22:53 | Feedback (0) | Filed Under [ Visual Basic Windows Presentation Foundation ]

Using WPF custom controls in VSTO app-level solutions

As you perhaps already know, you can add WPF controls to your VSTO solutions adding an ElementHost control onto Windows Forms user controls and then setting the Child property value of the ElementHost to a desired WPF control. I wrote an article some time ago about reaching this objective and that you can find here.   But you are not limited to adding only WPF controls provided by the Base Class Library. In fact, you can add to your VSTO solutions even custom WPF controls and this is what I’m going to show in this...

posted @ sabato 10 gennaio 2009 13:49 | Feedback (0) | Filed Under [ Visual Studio Tools for Office ]

WPF: sizing controls from other controls via databinding

During the last days inside the Visual Basic Tips & Tricks community forums we discussed about sizing Windows Presentation Foundation controls starting from other controls' size, using data-binding and XAML. Particularly an user asked how he could dinamically assign the width of a ProgressBar starting from the width of a Label, so that both controls could always have the same width. In this post I want to show you the solution I proposed and I'll demonstrate also how controls' width is updated at runtime with Visual Basic code. So we're talking about a WPF project in Visual Basic 2008. We have a simple grid:        ...

posted @ mercoledì 7 gennaio 2009 00:29 | Feedback (0) | Filed Under [ Visual Basic Windows Presentation Foundation ]

Enabling spell check in WPF applications

Did you already know that the TextBox and RichTextBox controls in Windows Presentation Foundation offer spell check support? Yes, just like Microsoft Word, so typed words are checked and correct alternatives are proposed via a popup menu. That's cool! But you can take the advantage of this only if your system is localized on English, French, Spanish and German languages. Anyway, spell check can be enabled just setting the SpellCheck.IsEnabled attached property to True as follows: <RichTextBox Name="Rtb1" SpellCheck.IsEnabled="True"/> and this is just what we need to obtain the following result: With just a half line of code we can implement...

posted @ sabato 3 gennaio 2009 16:22 | Feedback (0) | Filed Under [ Windows Presentation Foundation ]

Creating and consuming WCF services with VS 2008 Express Editions - part two

In my previous post we saw how to utilize Microsoft Visual Studio 2008 Express Editions to create and consume Windows Communication Foundation services: Visual Web Developer 2008 for the first task and Visual Basic 2008 for the second one, observing how VWD does all the "dirty" work to publish the service to Internet Information Services.   In this post we want to use exclusively Visual Basic 2008 Express, reconstructing from zero the project. After starting VB 2008 Express, the first step to cover is creating a Class Library project that we'll call WcfExpressTemplate. Once ready, to the project must be added two...

posted @ venerdì 2 gennaio 2009 19:43 | Feedback (0) | Filed Under [ Visual Basic Windows Communication Foundation Visual Studio Express Editions ]

Creating and consuming WCF services with VS 2008 Express Editions - part one

A question that I've often read inside the Visual Basic Tips & Tricks community forums is: "how do I create and consume WCF services if I have only Visual Studio 2008 Express Editions?". So in this post and in the next one we'll see right how to accomplish this. In this first post we'll see how to use Microsoft Visual Web Developer 2008 Express Edition to create a WCF service and Visual Basic 2008 Express Edition to consume the service, while in the next post we'll see how to use just Visual Basic 2008 to reconstruct the WCF service, publish to IIS and, consume...

posted @ venerdì 2 gennaio 2009 19:18 | Feedback (0) | Filed Under [ Visual Basic Windows Communication Foundation Visual Studio Express Editions ]

WPF: Printing FlowDocuments in Visual Basic 2008

In a previous post we saw how easy is printing Windows Presentation Foundations UI controls. But probably the most common scenario is printing documents, another simple task in WPF.   Also in this case we recur to the PrintDialog class but now we'll use a method called PrintDocument. In fact it's possible to call it for printing FlowDocument objects, a particular kind of dynamic WPF documents.    Let's start from the base, a un FlowDocument that will contain, in this particular example, some text taken from my Italian language article about the ADO.NET Data Services on the VB T&T community. Once you create...

posted @ venerdì 2 gennaio 2009 18:52 | Feedback (0) | Filed Under [ Visual Basic Windows Presentation Foundation ]

WPF: printing UI elements with Visual Basic 2008

Printing UI elements in Windows Presentation Foundation is a simple task. This can be accomplished via a method called PrintVisual from the PrintDialog class. This last class exposes, as you can imagine, the classical Print dialog and has a method called PrintVisual which can send to a physical o virtual printer any object of type System.Windows.Media.Visual like e.g. the most of WPF controls which are derived from it.   So let's see a very simple code example. In a WPF application created with Visual Basic 2008, the following XAML defines a simple grid with two rows; the first row...

posted @ venerdì 2 gennaio 2009 17:38 | Feedback (0) | Filed Under [ Visual Basic Windows Presentation Foundation ]

The first English post!

Hi All, I think that most of you already know me if you spend some time in the Italian Visual Basic Tips & Tricks community or if you read some articles I wrote for the MSDN Visual Basic Developer Center or CodeProject; but maybe you downloaded some source projects from CodePlex or Code Gallery and you liked them (hopefully!). I'm a Team member in the above mentioned VB T&T community and I'm a Microsoft MVP in Visual Basic development. I decided to start this new English language blog (and I have to thank the VB T&T guys for hosting) because while being an...

posted @ venerdì 2 gennaio 2009 17:24 | Feedback (0) | Filed Under [ Misc ]

Powered by:
Powered By Subtext Powered By ASP.NET