Bonjour!

Je teste VS2010 sur un projet WPF VS2008.

En design mode, ma fenetre WPF affiche une exception:
at
BoolToImageSourceConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) in \converters\BoolToImageSourceConverter.cs:line 26
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Run(Object arg)
at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
at System.Windows.Interop.HwndSource.SetLayoutSize()
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at MS.Internal.Designer.VSIsolatedDesigner.ViewHolder.Initialize()
at MS.Internal.Designer.VSIsolatedDesigner.ViewHolder..ctor(UIElement content)
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.get_ViewHandle()
at MS.Internal.Host.Isolation.IsolatedView.get_ViewHandle()
at MS.Internal.Designer.DesignerPane.LoadDesignerView()
Pourtant, le code compile et aucun problème, ni exception lors de l'exécution.

Voici le code de classe BoolToImageSourceConverter incriminée:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[ValueConversion(typeof(bool), typeof(ImageSource))]
    public class BoolToImageSourceConverter : IValueConverter
    {
        #region IValueConverter Membres
 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
       {
            return ( (bool)value ) ?
                ((System.Windows.Markup.ArrayExtension)parameter).Items[1]
                :
                ((System.Windows.Markup.ArrayExtension)parameter).Items[0];
 
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
 
            return ( (ImageSource)value == (ImageSource)(( (System.Windows.Markup.ArrayExtension)parameter ).Items[1] )) ?
                true
                :
                false;
        }
 
 
        #endregion
 
 
    }
Quelqu'un a t il une explication ?