Select to view content in your preferred language

Can a value in the cell of the datagrid act as a button or a hyper link?

816
2
06-16-2011 12:25 PM
DanDong
Deactivated User
Hi everyone,

I attach a screenshot to describe my question [ATTACH]7358[/ATTACH]. I am keen to know how to implement such things in silverlight. Any thoughts or ideas? Thank you!

In the picture you can see "Resource found" (with a underline) within "Resource within Buffer" column,  which acts as a button. When you click on the words, something will happen on the map.

"Click to see the statement" within "Notes" column acts as a hyperlink to open another pdf file.

And I want to ask another question (may sounds a little stupid ...) The headers of the columns are long and I don't know how to arrange them in two lines or make them auto wrap. It seems there is no property for header to wrap.

My design for the datagird is:
<slData:DataGrid x:Name="WirtReportDataGrid" Width="Auto" AutoGenerateColumns="False" HeadersVisibility="Column" Background="White" 
                             IsReadOnly="False" Grid.Row="1"
                             CanUserSortColumns="True">
            <slData:DataGrid.Columns>               
                <slData:DataGridTextColumn CanUserSort="True"  Header="Critical Resource" Binding="{Binding Key}"/>
                <slData:DataGridTextColumn CanUserSort="False" Header="Resource in Vicinity of Project Polygon"  Binding="{Binding Value.Prop1}"/>
                <slData:DataGridTextColumn CanUserSort="False" Header="Resource within Buffer" Binding="{Binding Value.Prop2}" />
                <slData:DataGridTextColumn CanUserSort="False" Header="Notes" Binding="{Binding Value.Prop3}"/>
            </slData:DataGrid.Columns>
        </slData:DataGrid>
0 Kudos
2 Replies
IgressT
Emerging Contributor
use DataGridTemplateColumn instead of DataGridTextColumn
0 Kudos
DanDong
Deactivated User
Thank you very much Doc 🙂 That works perfect!

I change my codes like below and get a hyperlink button, and with a button click event I can implement some actions against MyMap.
<slData:DataGridTemplateColumn Header="Critical Resource">
                    <slData:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <HyperlinkButton Content="{Binding Key}" Foreground="Black" Click="Hyperlink_Click"/>
                        </DataTemplate>
                    </slData:DataGridTemplateColumn.CellTemplate>
</slData:DataGridTemplateColumn>
0 Kudos