Hello,
I am new to WPF and utilizing the XamDiagram with mostly VB code-behind operations to configure it as well as manipulating nodes. I am looking for a way to fill a DiagramNode with an image that is located in my project resource file (My.Resources.xxxx.png) in VB code-behind. It isn't clear to me how to properly load an image from the project resources and get it converted to a brush and fill the node.
Thanks,
Matt
Hi,
I am glad that you have found the way. I think that other members can benefit from it as well.
M.Yovchev
I have was able to get an image loaded, but I have resorted to flagging the appropriate image files(in my project resources) to copy to the output directory, and then using the following code to create a DiagramNode. Unless there is an easier way, I may just stick to this method.
Dim image_src As ImageSource = New BitmapImage(New Uri("Resources\truck-48.png", UriKind.Relative))
Dim new_node As New DiagramNode
With new_node
.Foreground = New SolidColorBrush(Color.FromRgb(255, 255, 255))
.Stroke = New SolidColorBrush(Color.FromRgb(29, 29, 29))
.Height = 50
.Width = 50
.ShapeType = DiagramShapeType.Square
.Fill = New ImageBrush(image_src)
End With
image_src = Nothing