//Create a simple 2D line graphic and apply an existing line style item as the symbology.
//Construct on the worker thread
await QueuedTask.Run(() =>
{
//Build 2d line geometry
List<Coordinate2D> plCoords = new List<Coordinate2D>();
plCoords.Add(new Coordinate2D(1, 8.5));
plCoords.Add(new Coordinate2D(1.66, 9));
plCoords.Add(new Coordinate2D(2.33, 8.1));
plCoords.Add(new Coordinate2D(3, 8.5));
Polyline linePl = PolylineBuilder.CreatePolyline(plCoords);
//(optionally) Reference a line symbol in a style
StyleProjectItem lnStylePrjItm = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D");
SymbolStyleItem lnSymStyleItm = lnStylePrjItm.SearchSymbols(StyleItemType.LineSymbol, "Line with 2 Markers")[0];
CIMLineSymbol lineSym = lnSymStyleItm.Symbol as CIMLineSymbol;
lineSym.SetSize(20);
//Set symbolology, create and add element to layout
//An alternative simple symbol is also commented out below. This would elminate the four
//optional lines of code above that reference a style.
//CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid); //Alternative simple symbol
GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, linePl, lineSym);
lineElm.SetName("New Line");
});