0

I have the silverlight Datagrid like ,

enter image description here

I need to add one button in Every Row and If I click that button it will redirect to another page with particular row's Name Value.Because I need to show the Name value in the redirected Page.

Am new to Silverlight Application.Need your Guidance.

1
  • Dude there's a bunch of tutorials for this online, you're just looking to use DataGridTemplateColumn with a Button in it. Commented Jul 2, 2015 at 16:40

1 Answer 1

1

Chris is right there are lots of tutorials online however for anyone who gets to this site here is an example.

Your datagrid would look something like this

<sdk:DataGrid AutoGenerateColumns="False" Padding="15" Height="129" x:Name="dgSOF" Width="1021" ItemsSource="{Binding Path=TestListBinding}" RowHeight="30" BorderBrush="#FFE4E4E4">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Binding="{Binding Path=Something}" Header="Something"/>
                <sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Margin="5" Click="Button_Click" Width="100" Content="Click Me!"/>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>

And then the code behind would look something like this

private void Button_Click(object sender, RoutedEventArgs e)
    {
        string ClickedSomething = ((TestSL.TT)(((System.Windows.Controls.ContentPresenter)(VisualTreeHelper.GetParent(sender as Button))).DataContext)).Something;

        SilverlightMessageBoxLibrary.CustomMessage cm = new SilverlightMessageBoxLibrary.CustomMessage("You clicked on " + ClickedSomething, SilverlightMessageBoxLibrary.CustomMessage.MessageType.Error);

        cm.Show();
    }

This should point you in the right direction

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.