samedi 23 mars 2024

Keycloak: force user to update password by api (not by email)

 Hi all,

I had to implement keycloak for one of my latest project. Keycloak is a wonderful tools but in my opinion, there is a lack of clear documentation.

As I had to migrate users from an old webportal database to keycloak, I had to force users to reset their password at their next login in order comply to security password.


By reading on the documentation, the solution was to use the url :

PUT /admin/realms/{realm}/users/{id}/execute-actions-email


within the body  ; UPDATE_PASSWORD 


The problem is this code sends an email, and if the user doesn't click on the link (available 12h), the former password is still present.


Here is the solution if you just want to send a "force reset"

just take a look at the api documentation and search the user with the Put verb 

PUT /admin/realms/{realm}/users/{id}


this method has several option, but in order to force the password update, we have to add this on the body

{"requiredActions":["UPDATE_PASSWORD"]}

now, as soon as this user is updated, the user will have to enter en new password


Have a nice work


dimanche 21 mars 2021

Xamarin forms : access controls inside a CarouselView

Hi everyone,

By working on one of my project, I had to implement the wonderful CarrouselView. Actually, I think this control was really well written because it takes into account MVVM in some important itemporperties and events (see mircosoft doc for more info)

But I spend some time on a problem: how can I access control inside this carrousel if I want to interact with one of the child control? This becomes a bit tricky.

As any dev, I start by google it,  and the anwser was blurry.

So I decided to do by my own:

Watchout: 

  • this solution described in this article is not the most elegant, but I will at the end give some tips in order to the clean the code 😃 
  • I volontary did not use MVVM due to the separtion of the UI and the "business". 


Here are the "data" sources  classes:


The xaml that manage the carousel. You can see that is composed with a boxview, a label and a button. No rocket science. This boxview displays a color, a label displays the name of the color, and the button wants to launch a message box (displayAlert) with a simple message

In the constructor, I bind my item source

Here comes then the problem, if we wants to find any control inside de carousel, there is no way to access it


So, instead of tying to access the value, we can by code retrieves the several childeren

Let's explain quickly how to find the conrols:

  1. Get the carrousel control via the command this.Content.FindByName<CarouselView>("MyCarrousel");
  2. Get all the control inside the carrousel control via the command: caroussel.VisibleViews;

By this, we have all the conrols inside the carousel. In my example, I have volontary added a Grid, once the grid accessed, I get the controls and now, I can work with them.

Clean code


It could have been over, but you and I knows that this code is not clean at all, and the main problem is if we change any position of a control, this code either use the wrong control or crash.

So instead of  using the index of the device, it's esier to loop (with a foreach loop) any childeren against the type of control used. (don't forget to cast when you find the device)
Once again, I intentionnaly don't show the full answer, just to let you exercice yoursel

have fun.







dimanche 22 octobre 2017

Mircosoft annonce la fin du service Groove... Quid de mes apps?

Bonjour à tous,

Début octobre, Microsoft a envoyé un message nous signifiant l’arrêt du service groove, de sa musique et de ses api.
En tant qu'acteur sur le marché, ça a du sens. Par contre pour tous les développeurs, c'est quand même une tuile.

Microsoft préconise donc à ses utilisateur de migrer vers Spotify

Quand est il niveau dev? En faisant mes recherches sur les api Spotify: Je les ai trouvé assez compliqué à utiliser.

J'ai evalué les (le) concurrent(s) et je me suis rendu compte que Deezer faisaient parfaitement l'affaire. A tel point que je me suis même demandé pourquoi je n'ai pas sauté sur Deezer il y a 2 ans. Des api claires et facile d’acces (au premier abord)

Maintenant il ne reste plus qu'a implémenter tout.

Je documenterai les étapes de développement.

Bonne journée




mardi 9 mai 2017

Xamarin.forms : Add Splash screen (XF 2.3.4.234)

Hi all,

As I've installed VS2017, I took the time to do refactoring on my project in order to add new api.
So I've decide to start from a blank project and add my classes.

After several quirks, I've spent a lot of time to add a splash screen.
When I followed old fashion method or the method Xamarin describes on their website  I always had this error:
  • The file “obj\Debug\android\bin\packaged_resources” does not exist.

To solve that: It tooks time to find a correct sample all around the web.. but the sample (with project) to download in the xamarin website works well.


The main difference is : No layer list to create, and in the style.xml file,
there are those two more item

    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowActionBar">true</item>

Now everything works fine.

Good work.

lundi 28 septembre 2015

Utiliser les api de XboxMusic / Groove Music dans Windows 10

Bonjour à tous,

Voici un nouvel article afin de vous aider à vite incorporer de la musique en streaming sous Windows 10.
Ceci fonctionne aussi bien pour les autres plateformes Windows (W8,W8.1,WP8.0, WP8.1 (silverlight et RT)) (je n'ai pas encore testé android et IPhone sous Xamarin)

Cet exemple traité est juste la diffusion des 30 sec de streaming de présentation d'une chanson.

L'étape prerequis de lancer Visual Studio --> File--> new project, est surement acquise, donc je ne ferais pas l'affront d'en parler ici :-)

Première étape:

Se connecter au site de microsoft music et suivre les étapes pour obetnir une clé sur Azure. Tout est clairement expliqué sur le site


Seconde étape

Le plus simple est de télécharger le code mis en ligne sur Github . Il est complet et on peut réutiliser  toutes les fonctions : les infos sur un artiste, albums, chansons, Photos ...



Troisième étape

Télécharger la dernière version package XboxMusic sur nuget :-) . Lors de l'écriture de cet article nous sommes à la version 1.7.0





Quatrième étape

Télécharger la dernière version de la librairie JSON sur nuget 




Cinquième étape

Pour faire simple, j'ai créé un petit folder pour y mettre toutes les assemblies dont j'ai besoin.
Celles-ci sont disponibles pour la plus part dans le projet téléchargé précédemment
 sous github

voici les différentes assemblies à avoir: 
  • Microsoft.Threading.Tasks
  • Microsoft.Threading.Tasks.Extensions
  • Microsoft.Xbox.Music.Platform.Client
  • Microsoft.Xbox.Music.Platform.Contract
  • System.Net.Http.Extensions
  • System.Net.Http.Primitives

Sixième étape:

Il suffit juste d'importer le tout dans votre pojet. Je vais mettre un exemple pour jouer un morceau 

Dans cet exemple il y a un simple bouton et un MediaElement pour jouer le son.

Et le tour est joué 


Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Microsoft.Xbox.Music.Platform.Client;
using Microsoft.Xbox.Music.Platform.Contract.DataModel;


// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace MusicBoss
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        protected static string ClientInstanceId { get { return "XboxMusicClientTests12345678901234567890"; } }
        private IXboxMusicClient _client;
        public MainPage()
        {
            this.InitializeComponent();
        }

        private async void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _client = XboxMusicClientFactory.CreateXboxMusicClient("AzureProjectNAme", "AzureKey");
                
                string val = "music.F6DE7208-0100-11DB-89CA-0019B92A3933";
                StreamResponse son = await _client.PreviewAsync(val, ClientInstanceId, null);

                PrevMed.Source = new Uri(son.Url, UriKind.RelativeOrAbsolute);
               

                PrevMed.Play();
            }
            catch (FileNotFoundException ex)
            {
                string mess = ex.Message;
                throw;
            }
           
        }
    }
}

dimanche 13 septembre 2015

Reprise

Bon,

Ca fesait un petit bout de temps que je n'avais plus rien publié.
La tout, je suis de retour avec pas mal d'expérience en plus

Oracle (même si je deteste)
SQL server
Windows 10 universal app
Xamarin
Azure mobile app
Unit Testing
VS2015 - C#6
...

Aussi un peu plus de gestion de projets...

Stay tunes ;-)

mardi 22 juillet 2014

SQL server 2008: Unpredictable sort order from a select - Ordre de trie imprevisible lors d'un select

Hi all, I Just found a strange problem...
using SQL server 2008 with a large amount of data. I've created a query that just select a list of devices by serial number.
My select query of course returns all the set of data BUT not in the order I entered it!!!

This article confirms my problem

default-sort-order-when-using-select-no-order-clause

I'm searchin for a solution..


Bonjour à tous,

Je viens de tomber sur un problème assez etrange. Je crée un requete via sql server 2008 qui selectionne une liste de compteurs par numéro de série. Cette liste est bien sur qu'une partie de la totalité de mes compteurs.

Le soucis est que le résultat de ma requète ne reviens pas dans l'ordre dans laquelle ma requête fut faite.

Cette article en anglais parle du problème

default-sort-order-when-using-select-no-order-claus


samedi 29 juin 2013

WP7 binding problem: System.MethodAccessException: Attempt to access the method failed

This an easy and simple problem I faced recently but I waste a lot of time to understand it

For me this problem occured with VS2012 and WP7 project! 

So I explained my project was a simple soundboard.
This soundoard is just composed by a ListBox, and the datatemplate is composed by two buttons and one textbox.

When I build the project and I run it to the emulator

  1. It tooks a lot of time to load and run
  2. Buttons and text filed are empty
But in the Xaml and code, every fields are binded correctly.

Just by looking at the output windows, I had this message

"System.Windows.Data Error: Cannot get 'Description' value (type 'System.String') from 'BoardField' (type 'BoardField'). BindingExpression: Path='Description' DataItem='BoardField' (HashCode=84854501); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String').. System.MethodAccessException: Attempt to access the method failed: .BoardField.get_Description()
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
   at System.Reflection.RuntimePropertyInfo.InternalGetValue(PropertyInfo thisProperty, Object obA first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll
The program '[247333058] TaskHost.exe: Managed' has exited with code 0 (0x0)."


So, it seems that there is an accesibility problem.. By reading the info coming from this exception. It looks like it came from the class that contains data. Here is the class that cause problem


Code:
class BoardField
    {
        public string Hero { get; set; }
        public string Name { get; set; }
        public string Path { get; set; }
        public string Description { get; set; }
        public string Language { get; set; }
    }

Just by adding the accessor "public" 
Code:
public class BoardField
    {
        public string Hero { get; set; }
        public string Name { get; set; }
        public string Path { get; set; }
        public string Description { get; set; }
        public string Language { get; set; }
    }


So it seems that the for a WP7 project on WS2012 has wrong settings at project start.

Good Work

dimanche 26 mai 2013

MVVM: Intellisense for getting property name - Intellisense afin de retrouver le nom d'une propriete

By using MVVM,

We all know how boring is to write each name of property in the setter. Mistake, Mispelling lead to debugging.

Here is a small extension methond using linq in order to solve this problem:


Code:
using System;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Collections.ObjectModel;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


namespace Refre.Utils
{
    public static class Helper
    {
        public static void Raise<T, P>(this PropertyChangedEventHandler pc, T source, Expression<Func<T, P>> pe)
        {
            if (pc != null)
                pc.Invoke(source, new PropertyChangedEventArgs(((MemberExpression)pe.Body).Member.Name));
        }
    }
}

Now, we can easily use intellisense in order to find property while writting the setter. here is an example:
Code:
 private string btnName;
        /// <summary>
        /// Gets or sets the button drink name.
        /// </summary>
        public string BtnName
        {
            get { return btnName; }
            set 
            {
                if (!object.Equals(btnName, value))
                {
                    btnName = value;
                    PropertyChanged.Raise(this, o => o.BtnName);
                }
            }
        }
Good work

mercredi 15 mai 2013

Visual studio - Blend designer laisse une image fantôme tant qu'on ne compile pas

Bonjour à tous,

Je viens de tomber sur un nouveau soucis.
Il y a  peu de temps, j'ai réinstaller mon PC. Celui-ci comporte 2 GPU; 1 Nvidia puissant et un Intel moins puissant.

En travaillant sur des projets Windows phone, Quand je zoom ou de-zoom, le designer ne se rafraîchissais pas. Une image fantôme appariait


En gros, pour une raison inconnue, VS n'a pas configurer le PC pour que le designer soit pris en charge par la carte NVIDIA.

Pour résoudre ce problème, il suffit d'aller dans le panneau Nvidia: "Manage 3D setting" (hé oui mon Windows est en anglais)


Il faut choisir les executables: 
  • Blend.exe pour Blend
  • Xdesproc.exe pour le designer de visual studio


En relançant, tout devrais revenir en ordre. 

Bon travail à tous !





lundi 1 avril 2013

SQL Server : Autoriser la connexion à distance via SQL management Studio (SMSS) (French)

Bonjour,

On va dire que cet article aura pour but une fonction d'anti-sèche qu'un apport de connaissance.

J'ai souvent eu à travailler sur une base de donnée SQL server (peu importe l’édition) distante. Dans mon dernier projet, j'ai dû me connecter sur mon server via SMSS sur mon pc client et malheureusement j'ai eu un message d'erreur

La solution fut assez simple,  c'est d'enabler et de lancer le SQL brower.

Voici la procédure à suivre :
http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/

Bon travail

mercredi 30 janvier 2013

Windows Phone 8 (WP8) Emulator problems - Virtual switch error (french)

Mise à jour

Bonjour tous,

Suite à cet article, j'ai voulu continuer mon projet WP8. A ma grande surprise, il ne m’était plus possible de lancer l’émulateur WP8!!!

Bon, au lieu de continuer à lutter, je me suis lancer dans une réinstallation de mon Windows 8 (pfffff c'est lourd). Heureusement, Microsoft permet une réinstallation (selon eux) plus aisée sans avoir à utiliser de média (je répété, selon eux)
Voici un article exposant la procédure à suivre.

Apres plusieurs tests, je me rend compte que mon problème vient d'AVAST! 7 internet security.
Pour une raison qui m'est toujours obscure, le firewall bloque toute création de virtual switchs, que ce soit pour WP8 ou pour tout autre machine virtuelle.

Solution

Soit désinstaller Avast! internet security et le réinstaller en supprimant le firewall

Bon travail à tous!

-----------------------------------------------------------------------------------------------

Salut,

Voici un problème sur lequel je suis tombé en voulant tester ma première application WP8.
Je lance l'emulateur, celui-ci me donne plusieurs message d'erreurs:

le 1er



une fois cliqué sur le boutton "retry", une second message s'affiche

Ça prend un peu de temps mais pour finir, j'ai ce troisième message

Impossible donc de déployer mon application sur l’émulateur (génial :-( )


Quelques recherche sur le net et voila les pistes qui m'ont permis de résoudre:

Tout d'abord, vérifiez que vous n'avez pas de connections VPN ou même un autre système de machines virtuelles (VMware par exemple) si oui, malheureusement, il faudra les désinstaller.

Là, les choses deviennent de plus en plus compliquées:

il y a quelques articles en anglais essayant de guider vers une solution, voici les liens:
http://social.msdn.microsoft.com/Forums/en-US/wptools/thread/1734dac7-37a4-4d9a-bf89-42b6d493adda
http://stackoverflow.com/questions/13149509/windows-phone-8-emulator-error-something-happened-while-creating-a-switch

Mais rien n'a marché.

La solution la plus simple fut de re-installer le SDK WP8 avec la fonction "repair",  tout de même un plantage en fin d’opération.
Mais ça fonctionne.

Rien d’inédits, mais j'y ai quand même passé 4h a tout tester avant de décider de réinstaller. Si ça peut vous permettre d'y passer moins de temps.

Bon travail à tous!




mardi 3 juillet 2012

WCF beginner tutorial

For several years, I was looking for a good WCF tutorial.
I read documentation more or less from the time this technology was released (.NET3.0).

But honestly, I was a bit lost with so many ways to configure everything.
I attend a short training and honestly, at the end I was still "offside".

I start to read great books, but something was still missing

Then, I remember some times ago I found interesting webcasts

The first one is in english
webcast from dasblonde.net
this webcast is complete


The second one is in french and i think it's amazing...
Webcast msdn
Quick, complete, simple but crystal clear.


Good work

lundi 25 juin 2012

Conformity : Silverlight 4 Business application (presentation)


This is a post about an application named conformity made for a company. This app manages any non-appliance on the inbound and outbound material.

I’ll dig into the code later in another post but at this stage, I will just explain how it works.
The technology chosen to create this app is Silverlight in the version 4.

It was quite interesting to use this part of the Silverlight development tool but honestly, as worth it is to develop, as complex it is to deploy when you’re a novice on deployment.

I face some small problem during the development, but one of the dumbest was that it was not possible to interop with Outlook. It’s only possible whether you create an “out-of-browser” Silverlight app. So why not use WPF???

If I had to redo the same app, I rather prefer to play with ASP.NET MVC3 (or 4)

Let’s explain some pictures
The first picture shows only the lay out and the menu.
The layout is the classic template that Microsoft offers when a new SLBA (SilverLight Business Application) start.
SLBA 4 offers a mechanism of user management, easy to use. The user just has to click on the login button. A pop up will appear and the user can login or register if it was not done before.



The second picture shows the one of main windows. Some filter, a grid with all the material listed. A small text field with the reason of the non-compliance.
User can create a new non-compliance by clicking on the “new button” or modify an existing non-compliance.


The third picture shows the same info than the second one, but there is only one point that was added: the button report. Actually, the Client N.C. has to generate report.



The fourth picture shows when user modifies an existing N.C. (non-compliance)



 The fifth picture shows when user adds a new N.C. (non-compliance)

 The sixth picture and seventh shows a preview of a report containing info and status about the N.C.




The eighth picture and nine shows the medication name


And the last one shows the  customer name.


Then now, we will have a look to the code and some bugs and tricks I had to face



vendredi 18 mai 2012

xml file to a flatten list using Xlinq (Linq to xml) (+Namespace problem)

Here is once again a simple problem I faced recently.

I had this xml file and I'd like to flatten it to a list of actors in c#




<?xml version="1.0" encoding="utf-8" ?>
<MyDbCollection xmlns="http://www.Example.com">
  <Actors>
    <Actor FirstName="Will" LastName="Smith">
      <birthday date ="25.09.1968"/>
      <Movie name="Men in Black" Date="1999"/>
      <Movie name="Wild wild west" Date="1999"/>
      <Movie name="Ali" Date="2002"/>
    </Actor>
    <Actor FirstName="Jason" LastName="Statham">
      <Movie name="The Transporter" Date="2002"/>
      <Movie name="Revolver" Date="2005"/>
      <Movie name="The Bank Job" Date="2008"/>
      <Movie name="Transporter 3" Date="2008"/>
    </Actor>
    <Actor FirstName="Edward" LastName="Norton">
      <birthday date="18.08.1969"/>
      <Movie name="The Incredible Hulk" Date="2008"/>
      <Movie name="Fight Club" Date="1999"/>
      <Movie name="American History X" Date="1998"/>
    </Actor>
  </Actors>
</MyDbCollection>


There are many reason to flatten a list, so I won't enumerate any one of those.
So lets start:

As I want to use a list of "Actors", I create a class of actor:

 public class Actors
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Name { get; set; }
        public string Date { get; set; }
    }

As you can see, I don't need the birthdate value (for the example purpose)

With a simple Xlinq request, it quite easy to cover the xml file... just make sure to understand between the Descandants() and the Elements() method.


class Program
    {
        static void Main(string[] args)
        {
            string file =
                @"G:\ConsoleApplication1\ConsoleApplication1\bin\Debug\Test.xml";
            ReadXmlFile(file);
        }

        private static void ReadXmlFile(string fileName)
        {
            XDocument indexDoc = XDocument.Load(fileName);
            var reader = from a in indexDoc.Root.Descendants().Descendants()
                         from b in a.Elements()
                         
                         select  new Actors
                                    {
                                        FirstName = a.Attribute("FirstName").Value,
                                        LastName = a.Attribute("LastName").Value,
                                        Name = b.Attribute("name").Value,
                                        Date = b.Attribute("Date").Value
                                    };
            var test = reader.ToList();
        }
    }

If you run this code, you'll get this result:



Actually this code should have been correct whether the node <birthday> was not present in the datasource (xml file)

So, let solve this problem... 
Having a look to the MSDN documentation, we see that by adding the name of the node, we can filter only the nodes that the code need.
But if you try, you'll see in this example that nothing will occur.
The reason is quite simple, the xml file contains a namespace so, an namespace should be added in the code in order to make it run correctly.

So an object XNamespace will help to add a namespace to the XML object. Just add the namespace object to the node to reach.

here is the finale code:



private static void ReadXmlFile(string fileName)
        {

            XNamespace ns = "http://www.Example.com";
            XDocument indexDoc = XDocument.Load(fileName);
            var reader = from a in indexDoc.Root.Descendants().Descendants()
                         from b in a.Elements(ns + "Movie")

                         select new Movie
                                    {
                                        FirstName = a.Attribute("FirstName").Value,
                                        LastName = a.Attribute("LastName").Value,
                                        Name = b.Attribute("name").Value,
                                        Date = b.Attribute("Date").Value
                                    };
            var test = reader.ToList();
        }

Good work ;-)

dimanche 13 mai 2012

Quick extension method to convert a yes/no value to a boolean

Once again, I'm not re-inventing the wheel,
Here are simple code, extension method in order to translate a yes/no (Y/N) value read somewhere to a boolean.



 public static class YesNoToBoolExtension
    {
        public static bool YesNotoBool(this string source)
        {
            return source.ToUpper() == "Y"||source.ToUpper()=="Yes";
        }

        public static bool YesNotoBool(this char source)
        {
            return char.ToUpper(source) == 'Y';
        }
    }

Good work ;-)

dimanche 15 avril 2012

Check if any string starts with any string defined in a string array

Once again, a simple problem

I want to check whether a string starts with any string in a list (it easy to make it with a character ).
My current implementation in C# is as follows, One of the easiest implementation is to create an extension method


Code:
public static class StringExtensions
    {
        public static bool StartsWithAny(this string str,params string[] values)
        {
            if (!string.IsNullOrEmpty(str) || values.Length > 0)
            {
                foreach (string value in values)
                {
                    if (str.StartsWith(value))
                    {
                        return true;
                    }
                }
            }
            return false;
        }
    }

Nothing really hard to understand I think Good work ;-)

lundi 9 avril 2012

XmlDataProvider GroupBy an item in a DataGrid (two way binding)

This post will be done in english.

I'm not reinventing the wheel but I just had to implement this a simple datagrid grouped by a certain type of value. The datasource of the datagrid come from an XmlDataProvider.

Here is the xml file sample:


<?xml version="1.0" encoding="utf-8" ?>
<ListeDePrix>
  <Articles nom="Telephone" value="15"  vente="500" location="60,00" />
  <Articles nom="Telephone" value="50"  vente="450" location="45,50" />
  <Articles nom="Telephone" value="250" vente="300" location="35,50" />
  
  <Articles nom="Television" value="15"  vente="600" location="55" />
  <Articles nom="Television" value="50"  vente="500" location="50" />
  <Articles nom="Television" value="250" vente="400" location="30" />
  
  <Articles nom="Tablet" value="15"  vente="475" location="40" />
  <Articles nom="Tablet" value="50"  vente="425" location="37"  />
  <Articles nom="Tablet" value="250" vente="375" location="32"  />
</ListeDePrix>

Here is the XAML file:

<Window.Resources>
        <XmlDataProvider x:Key="xmlfile" Source="XMLtest.xml" XPath="ListeDePrix/Articles"/>
    </Window.Resources>
    <StackPanel>
        <DataGrid AutoGenerateColumns="False">
            <DataGrid.Resources>
                <CollectionViewSource x:Key="items" Source="{Binding Source={StaticResource xmlfile}}">
                    <CollectionViewSource.GroupDescriptions>
                        <PropertyGroupDescription PropertyName="@value" />
                    </CollectionViewSource.GroupDescriptions>
                </CollectionViewSource>
            </DataGrid.Resources>
            <DataGrid.ItemsSource>
                <Binding Source="{StaticResource items}"/>
            </DataGrid.ItemsSource>
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding XPath=@nom, Mode=TwoWay}" Header="nom"/>
                <DataGridTextColumn Binding="{Binding XPath=@value, Mode=TwoWay}" Header="value"/>
                <DataGridTextColumn Binding="{Binding XPath=@location, Mode=TwoWay}" Header="Renting price"/>
                <DataGridTextColumn Binding="{Binding XPath=@vente, Mode=TwoWay}" Header="Sell price"/>
            </DataGrid.Columns>
            <DataGrid.GroupStyle>
                <GroupStyle />
            </DataGrid.GroupStyle>
        </DataGrid>
        <Button Content="Save" Height="23" Name="button1" Width="75" HorizontalAlignment="Left" Click="button1_Click" />
    </StackPanel>

I've added some code behind in order to be able to save the data into the xml file.



Code:
 private void button1_Click(object sender, RoutedEventArgs e)
        {
            XmlDataProvider xmlfile = (XmlDataProvider)FindResource("xmlfile");

            string source = xmlfile.Source.LocalPath;
            xmlfile.Document.Save(source);
        }

mercredi 4 avril 2012

Certification Microsoft


Voilà, le 22 mars 2012, j’ai entrepris de passer ma certification Microsoft. Celle-ci est la 70-511 : .NET Framework 4 Windows application. Je l’ai réussie et j’en suis bien heureux. 







samedi 31 mars 2012

1er blog

Bon, voilà, il était temps pour moi de faire mon blog. j'y palcerai des articles en français et en anglais. Bon, cesse de perte de temps et je me lance dans mes 1er post.