Bonjour,
Je travaille sur Visual Studio 2008 standard Beta 2 avec un projet Windows Application en WPF.
Mon projet contient:
- 1 Fenêtre: Window1
- 1 UserControl: Altimeter
- 1 Ressource: /Resources/Altimeter.png
Voici mon code
Window1:
Altimeter:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <Window x:Class="LOICPDotNET.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:LOICPDotNET" Title="Window1" Height="300" Width="300" Closing="Window_Closing"> <Canvas> <local:Altimeter /> </Canvas> </Window>
Dans mon Window1 j'ai une erreur Could not create an instance of type 'Altimeter', à la ligne en rouge plus haut.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <UserControl x:Class="LOICPDotNET.Altimeter" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Canvas Width="200" Height="200"> <Canvas.Background> <ImageBrush ImageSource="pack://application:,,,/Resources/Altimeter.png" /> </Canvas.Background> </Canvas> </UserControl>
L'erreur se produit lorsque j'utilise mon image en ressource dans mon Altimeter (UserControl). Si je retire l'image du code de l'Altimeter, plus d'erreur dans Window1. Lorsque j'édite pour Altimeter, l'image s'affiche bien, pas de soucis.
Je ne vois pas trop d'où proviendrait l'erreur qui pour le coups ne nous dis pas grand chose sur le problème...
Merci.
Partager