Spread Silverlight can be customized to show various formats of data. In this blog we will discuss an approach to show Hyperlink Cells in Spread Silverlight. This hyperlink cell will have some web link, which opens a web page in browser. We can put a hyperlink button in a cell which allow the users to navigate to some web site. This is very useful in cases where you want to keep the content on your website to least. You can provide links to other informative pages in cells which makes your website look smooth. We need to create a custom cell with a hyperlink button in it. It is easy to create custom cells in Spread Silverlight with not much trouble by inheriting CustomDrawingObject class.

Let see how we can do this in 3 easy steps :)

1. Create a custom object which inherits this CustomDrawingObject


public class ControlDrawingObject : CustomDrawingObject  
{  
    private Control _rootElement;  
    public ControlDrawingObject(int row, int col, Control control) : base(row, col) { _rootElement = control; this.ShowDrawingObjectOnly = true; }  
    public override FrameworkElement RootElement  
    {  
        get { \_rootElement.Margin = new Thickness(1); return \_rootElement; }  
    }  
}  

2. Create a silverlight hyperlink button and use it as a DrawingObject. Using this DrawingObject, create a custom sheet by inheriting the base WorkSheet class


public class MyWorksheet : Worksheet  
{  
    public bool DrawingObjectVisible { get; set; }  
    public override DrawingObject[] GetDrawingObject(int row, int column, int rowCount, int columnCount)  
    {  
        if (row != 1 || column != 1) return base.GetDrawingObject(row, column, rowCount, columnCount);  
        DrawingObject dobj;  
        dobj = new ControlDrawingObject(row, column, new HyperlinkButton() { Content = "This is a link", NavigateUri = new Uri("http://www.google.com") });  
        return new DrawingObject[] { dobj };  
    }  
}  

3. Lastly, add an object of this custom worksheet to GcSpreadSheet


    this.gcSpreadSheet1.Sheets.Clear();  
    this.gcSpreadSheet1.Sheets.Add(new MyWorksheet());  
    var sheet = this.gcSpreadSheet1.ActiveSheet;  

So this small code snippet completes the implementation process and creates a hyperlink cell in Spread Silverlight. To see it in action, you may download the sample with the complete implementation from below mentioned link. Download Sample