I am trying to create a DataGrid that has "clickable" text located within it. In the example I provide I would like to click on the Bid
or Ask
price and have a handler triggered. I guess it would be like having a hyperlink that triggers a function instead of a browser. The handler will be used to populate a list with the data located in the selected Bid
or Ask
row. I'm not sure how to approach this and any advice will be greatly appreciated.
What I have now:
XAML
<UserControl.Resources>
<local:Options x:Key="Options"/>
</UserControl.Resources>
<DataGrid AutoGenerateColumns="True"
Grid.Row="0"
Grid.Column="1"
RowHeaderWidth="0"
AlternationCount="2"
x:Name="AGrid"
ItemsSource="{StaticResource Options}"
CanUserAddRows="False"
ColumnWidth="*"
IsReadOnly="True">
</DataGrid>
C#
public class Option
{
public int Strike { get; set; }
public int Bid { get; set; }
public int Ask { get; set; }
public Option()
{
}
}
public class Options : List<Option>
{
public Options()
{
this.Add(new Option() { Strike = 120, Bid = 20, Ask = 25 });
this.Add(new Option() { Strike = 130, Bid = 30, Ask = 35 });
this.Add(new Option() { Strike = 140, Bid = 40, Ask = 45 });
}
}
}