Hi,
Is it possible to create a custom node template that takes a data object containing an image URL, so that the node is an image and some text?
Thank you!
|
var template = new DataTemplate(() =>
{
StackLayout stacklayout = new StackLayout();
stacklayout.WidthRequest = 200;
stacklayout.HeightRequest = 230;
stacklayout.VerticalOptions = LayoutOptions.FillAndExpand;
stacklayout.HorizontalOptions = LayoutOptions.FillAndExpand;
stacklayout.Orientation = StackOrientation.Vertical;
Image image = new Image();
image.Source = "https://media.geeksforgeeks.org/wp-content/cdn-uploads/gfg_200x200-min.png";
stacklayout.Children.Add(image);
Label label = new Label()
{
TextColor = Color.Red,
Text = "Image",
FontSize = 10,
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand
};
stacklayout.Children.Add(label);
return stacklayout;
});
//Initialize node with template.
Node node = new Node() { Width = 200, Height = 230, OffsetX = 300, OffsetY = 60, Template = template };
node.Style.Brush = new SolidBrush(Color.Transparent);
node.Style.StrokeBrush = new SolidBrush(Color.Transparent);
diagram.AddNode(node); |
Hi,
I’ve added a binding for the image source when applying a data source to the diagram and some data binding for the text.
The data binding for the text comes through OK but the image does not (its a remote URL for the data binding).
Is there an issue with the control or a particular way to apply data binding?