开发者

bound picture to control in WPF without using converter

开发者 https://www.devze.com 2023-04-02 08:53 出处:网络
i\'m having a custom object with Picture as a string (file name only) and i want to display. the problem is that the image is stored in \"images\" directory of the project so the full path is now \"i

i'm having a custom object with Picture as a string (file name only) and i want to display.

the problem is that the image is stored in "images" directory of the project so the full path is now "images/{image name}"

how can i bind it correctly ?

i can do it easily with converter i guess, but is there any way to avoid it like: <Image Source="{Binding Path=FullPath+"/"+Pict开发者_Go百科ure}"> ?


You could bind to an aggregated property in your ViewModel and then put whatever path you like into that. That way the ViewModel becomes the 'converter'.

0

精彩评论

暂无评论...
验证码 换一张
取 消