How to Set the Source Property for a WPF Image?
Posted: Fri Jul 16, 2010 4:03 pm
My explorations of WPF/XAML continue - here's the latest obstacle I've met.
I have a Window which contains an Image, here's the XAML defining the Image...
<Image Height="356" HorizontalAlignment="Left" Margin="0,59,0,0" Stretch="Fill"
VerticalAlignment="Top" Width="394" Name="imgArticle"
Source="d:\dick\temp\saucy.jpg" />
The Window displays the Image correctly.
But I want to change the Source within my APL code, and all I get is DOMAIN ERROR...
Exploration shows me...
]displayr {(⎕DR ⍵)(⍴⍴⍵)(⍴⍵)⍵}frmAcquire.imgArticle.Source
┌4─────────────────────────────────────────────┐
│ ┌1─┐ ┌0─┐ │
│ 326 │ 0│ │ 0│ file:///d:/dick/temp/saucy.jpg │
│ └~─┘ └~─┘ │
└¯2────────────────────────────────────────────┘
So I know that Source is a Pointer (some sort of dog?), and just assigning a character vector won't cut any mustard (tried it, got a DOMAIN ERROR). Read the DotNet Interface Guide, and found out about ByRef, so...
p←⎕new ByRef (⊂'file:///d:/dick/temp/saucy.jpg')
]displayr {(⎕DR ⍵)(⍴⍴⍵)(⍴⍵)⍵ ⍵.Value}p
┌5────────────────────────────────────────────────────────────┐
│ ┌1─┐ ┌0─┐ ┌30────────────────────────────┐ │
│ 326 │ 0│ │ 0│ Dyalog.ByRef │file:///d:/dick/temp/saucy.jpg│ │
│ └~─┘ └~─┘ └──────────────────────────────┘ │
└¯2───────────────────────────────────────────────────────────┘
But...
frmAcquire.imgArticle.Source←p
DOMAIN ERROR
frmAcquire.imgArticle.Source←p
∧
frmAcquire.imgArticle.Source←⊂p
DOMAIN ERROR
frmAcquire.imgArticle.Source←⊂p
∧
I'm sure I'm missing something glaringly obvious - anyone care to enlighten me? I've looked at the Microsoft site and see similar questions asked, but the answers seem to go into a maze of data bindings and so forth - not only incomprehensible to a dumb APLer, but seeming to avoid my wildly rash concept that "the image should come from whatever file the user decides they want to look at".
I have a Window which contains an Image, here's the XAML defining the Image...
<Image Height="356" HorizontalAlignment="Left" Margin="0,59,0,0" Stretch="Fill"
VerticalAlignment="Top" Width="394" Name="imgArticle"
Source="d:\dick\temp\saucy.jpg" />
The Window displays the Image correctly.
But I want to change the Source within my APL code, and all I get is DOMAIN ERROR...
Exploration shows me...
]displayr {(⎕DR ⍵)(⍴⍴⍵)(⍴⍵)⍵}frmAcquire.imgArticle.Source
┌4─────────────────────────────────────────────┐
│ ┌1─┐ ┌0─┐ │
│ 326 │ 0│ │ 0│ file:///d:/dick/temp/saucy.jpg │
│ └~─┘ └~─┘ │
└¯2────────────────────────────────────────────┘
So I know that Source is a Pointer (some sort of dog?), and just assigning a character vector won't cut any mustard (tried it, got a DOMAIN ERROR). Read the DotNet Interface Guide, and found out about ByRef, so...
p←⎕new ByRef (⊂'file:///d:/dick/temp/saucy.jpg')
]displayr {(⎕DR ⍵)(⍴⍴⍵)(⍴⍵)⍵ ⍵.Value}p
┌5────────────────────────────────────────────────────────────┐
│ ┌1─┐ ┌0─┐ ┌30────────────────────────────┐ │
│ 326 │ 0│ │ 0│ Dyalog.ByRef │file:///d:/dick/temp/saucy.jpg│ │
│ └~─┘ └~─┘ └──────────────────────────────┘ │
└¯2───────────────────────────────────────────────────────────┘
But...
frmAcquire.imgArticle.Source←p
DOMAIN ERROR
frmAcquire.imgArticle.Source←p
∧
frmAcquire.imgArticle.Source←⊂p
DOMAIN ERROR
frmAcquire.imgArticle.Source←⊂p
∧
I'm sure I'm missing something glaringly obvious - anyone care to enlighten me? I've looked at the Microsoft site and see similar questions asked, but the answers seem to go into a maze of data bindings and so forth - not only incomprehensible to a dumb APLer, but seeming to avoid my wildly rash concept that "the image should come from whatever file the user decides they want to look at".