Browse by Tags

[WPF] Custom Check Box Template

Once again, let’s enjoy the WPF’s flexibility to change any style and template. In this case, I’ve customised the Check Box’s style to get the next appearance:

 Unchecked

 UnChecked

 Checked

 Checked

 Focus

 focus

Mouse Over

mouseOver

 

You can download  the code from here. 

My example is based on this good MSDN article about Check Box’s template. There you can also find templates for other controls.

Posted 26 February 10 01:01 from Escuchoyo | 0 Comments   
Filed under
[WPF/WCF] DataGrid + DoubleClick + MVVM + Loading Splash (description & code)

Using the DataGrid WPF Toolkit, this post shows a simple client/server application to fill a DataGrid according to the information that is provided by a WCF service. When any row receives a double click, a new document (jpeg or docx for this example) is opened by an external application.

WPFDataGridExampleLoading

WPFDataGridOpenDocument

The application is designed using MVVM pattern, where View and ViewModel are placed in the client side and Model in the server side. In our example, we will show a set of “Alerts” in a DataGrid , so that we will have the next elements:

  • Model: Alert. This class provide all the information about an “Alert” entity.
  • View: Custom DataGrid with all the alerts
  • ViewModel: Intermediary element between Model and View to decouple the alert model from its view. In our case,  ViewModel provides a collection of alerts and a command to open its associated document.

About the DataGrid control, I would like to highlight the next points:

  • Double click behavior in DataGrid control using attached properties. See the new HandleDoubleClick and TheCommandToRun properties in DataGrid, which are declared in WpfApplication.TestGridView => AttachedProperties => SelectorDoubleClickCommandBehavior.cs
  • Using DataGridTemplateColumn: I got some problems trying to apply padding in the cell content, regarding the rest styles and behaviors (see Themes folder). To resolve it, I’ve used a DataGridTemplateColumn, which allows integrate any custom content in a cell. In this way, I’m using a TextBlock with a specify margin to simulate that padding.

In the server side (WCF service), I’ve implemented a request/response messages architecture, so that it would be easier and scalable to add other functionality like delete or create alerts (see the service implementation in WcfService.ServiceLibrary => AlertsService.cs, as well as the retrieve messages and handler).

Download source (VS2008)

This application is based on different sources, which can be found below. At the same time, I would like to be grateful to my workmate Wael, who is a great developer and he always gives me great advices.

Useful Links:

Posted 07 January 10 10:02 from Escuchoyo | 0 Comments   
Filed under ,
[WPF] Custom Listbox (description and source code)

WPF allows to create custom controls with flexibility. In this case, I’ll show you a custom Listbox with the follow interesting features:

  • Resizeable (listbox and its items)
  • Custom items with text and picture
    • Mouse over effect with custom color
    • Selected item with custom background color
  • Items Source from Binding. In my example, I’ve used a collection of “Customer” objects to fill the elements of the listbox, simulating that they are provided by a external service, as well as each picture is a array of bytes inside of “Customer” type.
  • Custom converters in binding fields:
    • To fill each picture (array of bytes) in a Image object

<Image  Margin="2" Stretch="Uniform"  Source="{Binding Path=Image,Converter={StaticResource LocalByteArrayToImageConverter}}"/>

    • To format the address in line. Address is another custom type “Address” inside of “Customer”. Using another converter, we can take the desired fields that we want to show and how we want to do it

<TextBlock Text="{Binding Path=FullAddress, Converter={StaticResource LocalAddressToFullAddressConverter}}"  Style="{StaticResource TextBlockContentStyle}" />

image

DOWNLOAD CODE HERE

Posted 02 November 09 10:00 from Escuchoyo | 0 Comments   
Filed under
Pasar de Flash a XAML (WPF o Silverlight)

[previously on Escuchoyo]

Después de 3 semanas de aislamiento en las islas maltesas, volvemos a la carga con las pilas cargadas. Se agradece de vez en cuando el salir de este mundo "com***rizado" !

................. 

Ya tenemos un progamita ( no free! ) que nos permite pasar automáticamente los archivos SWF de flash 8.0 a código XAML, pudiendo transformar nuestras aplicaciones Flash en aplicaciones de WPF o Silverlight.

La guerra entre ambas plataformas está comenzando a ser bastante dura. De momento, creo que Flash continúa con la mayor parte del terrero, y continúa luchando por ello, así lo demuestra con algunas de las últimas característica tal como Action Script 3.0 o Flash 9 para Linux.

Veremos como termina el asunto....

La url donde encontrareis toda la informaciónde dicho programa es: http://www.theconverted.ca/  

Posted 27 September 07 02:01 from Escuchoyo | 0 Comments   
Filed under , ,