Autor Beitrag
new.Matrix
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 07.03.08 16:57 
Hallo zusammen

Ich möchte ein Image einbinden, dies klappt ja eigentlich, aber nur wenn ich den ganzen Pfad angebe. wenn ich einen relativen pfad, also "/images/bild.gif" eingebe klappts nicht und ich habe den Ordner image schon überal im Projektordner hinkopiert! Kann mir jemand helfen?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 07.03.08 17:07 
Hast Du beim zweiten Parameter des Uri-Konstruktors auch UriKind.Relative übergeben?

Eventuell müssen da noch Punkt(e) vor den ersten Schrägstrich im Pfad?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
new.Matrix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 07.03.08 17:13 
Nein ich habe keinen Urikind angegeben. Wie mach ich das in XAML?

Ich rufe das Bild so auf:
ausblenden XML-Daten
1:
2:
3:
4:
5:
                <Image HorizontalAlignment="Left" Width="19" Height="19" Margin="550,0,0,4">
                    <Image.Source>
                        <BitmapImage UriSource="/Images/1.gif" />
                    </Image.Source>
                </Image>


Moderiert von user profile iconChristian S.: C#- durch XML-Tags ersetzt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 07.03.08 17:15 
Ach so, in XAML. Laut Doku brauchst Du das nicht, nur den ersten Schrägstrich musst Du wohl weglassen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
new.Matrix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 07.03.08 17:30 
Hmmm... habs jetzt so versucht, aber hat leider auch nicht geklappt, habe extra den Image Ordner in alle möglichen Ordner des Projektes kopiert :-S
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 07.03.08 17:41 
Also wenn man einfach die Source-Eigenschaft des Images mit "Images/1.gif" besetzt, dann geht es. Wozu brauchst Du das BitmapImage, kannst Du drauf verzichten?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
new.Matrix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 07.03.08 17:56 
Also erstmals danke für deine Mühe und Hilfe!

Leider klappts bei mir immer noch nicht, jetzt kommt ne exception Cannot locate resource 'images/1.gif' obwohl der Ornder so ziemlich überall ist :-S ich raffs echt nicht
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 07.03.08 18:22 
user profile iconnew.Matrix hat folgendes geschrieben:
Also erstmals danke für deine Mühe und Hilfe!
Kein Problem, dafür gibt's das Forum ja :-)

user profile iconnew.Matrix hat folgendes geschrieben:
Leider klappts bei mir immer noch nicht, jetzt kommt ne exception Cannot locate resource 'images/1.gif' obwohl der Ornder so ziemlich überall ist :-S ich raffs echt nicht

Überall muss der Ordner nicht sein, sondern da, wo Deine exe liegt. ;-)

Ich habe für meinen Test eben in meiner Solution im Visual Studio einen neuen Ordner angelegt und dann mittels "Add" -> "Existing Item" eine Bilddatei hinzugefügt. Bei der Bild-Datei dann in den Eigenschaften "Build Action" auf "None" und "Copy to Output Directoy" auf "Copy if newer". Ich hab mal einen Screenshot angehangen.

Wenn ich nun mein Projekt erstelle, wird automatisch der Unterordner im Debug- bzw. Release-Ordner erstellt und die Datei dort rein kpoert.
Einloggen, um Attachments anzusehen!
_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
new.Matrix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 07.03.08 18:27 
Danke du bist mein Held! :-D

Nun klappts auch bei mir! Bin halt noch ein Newbe auf diesem Gebiet...