ตั้งค่าอิมเมจต้นฉบับของการควบคุมรูปภาพ

ฉันเขียนโปรแกรมสำหรับ Windows Phone 8.1 ฉันใช้วิธีนี้เพื่อสร้างรูปภาพและตั้งค่าแหล่งที่มาของรูปภาพ:

Dim AgreeBitmapImage As BitmapImage = New BitmapImage()
AgreeBitmapImage.setsource(New Uri("Assets/Image/Agree.png", UriKind.Relative))
//Above line gives an error
imgAccept = New Image
imgAccept.Height = 40
imgAccept.Width = 40
imgAccept.Source = AgreeBitmapImage

เมื่อฉันเริ่มโปรแกรมจำลอง มันไม่ทำงาน ทำไม (พูดผิด)


person Amin    schedule 06.08.2014    source แหล่งที่มา


คำตอบ (1)


ใน Windows Phone 8.1 ทรัพยากรเช่น png ควรใช้ ms-appx:

AgreeBitmapImage.UriSource = 
    New Uri("ms-appx:///Assets/Image/Agree.png", UriKind.Absolute) 
person Chris Shao    schedule 06.08.2014
comment
คุณควรใช้ UriSource แทนเมธอด setSource - person Chris Shao; 06.08.2014