Unable to cast type isse in silverlight

Posted by prince23 on Stack Overflow See other posts from Stack Overflow or by prince23
Published on 2010-05-13T14:00:31Z Indexed on 2010/05/13 14:04 UTC
Read the original article Hit count: 485

Filed under:

error

once i clcik on the button i am getting this error. this is my code

<sdk:DataGrid MinHeight="100" x:Name="dgCounty" AutoGenerateColumns="False" VerticalAlignment="Top"   IsReadOnly="True"  Margin="5,5,5,0" RowDetailsVisibilityChanged="dgCounty_RowDetailsVisibilityChanged"  RowDetailsVisibilityMode="VisibleWhenSelected">
                <sdk:DataGrid.Columns>
                   <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="+" Click="Button_Click"></Button>
                        </DataTemplate>

private void Button_Click(object sender, RoutedEventArgs e) { Button btnExpandCollapse = sender as Button;

            var Row = DataGridRow.GetRowContainingElement(sender as FrameworkElement);
            if (Row.DetailsVisibility == Visibility.Collapsed)
            {
                Row.DetailsVisibility = Visibility.Visible;
            }
            else
            {
                Row.DetailsVisibility = Visibility.Collapsed;
            }



            if (btnExpandCollapse.Content.ToString() == "+")
            {
                btnExpandCollapse.Content = "-";
            }
            else if (btnExpandCollapse.Content.ToString() == "-")
            {
                btnExpandCollapse.Content = "+";
            }


        }

 void dtg_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e)
        {

            DataGrid RowDetails = e.DetailsElement as DataGrid

            if(RowDetails.YourDesiciveFlag = true)
            {

            }
             else
              {

            }


        }
}

working on this issue from past 3 days any idea how to solve this issue. just going mad on this issue. for expand /collpase in data grid in silverlight.

let me know if you people can provide me any code that can solve my issue.

thanks in advance prince

© Stack Overflow or respective owner

Related posts about silverlight-4.0