Silverlight Master/Detail DataGrid. How to access Detail DataGrid to set ItemsSource?

In a typical Master/Detail situation...

 I have a DataGrid. The ItemsSource of this DataGrid is set in the Completed event of a WCF call - (grdMaster.ItemsSource = e.Result) - where the x:Name of the grid is grdMaster. This is all 100%.
 However, when adding a Detail Datagrid inside the master grids DataTemplate and naming it appropriately... my codebehind does not recognise the detail grid. So plainly put, I cannot set the ItemsSource of grdDetail like I do with grdMaster.So how i can fill my detail datagrid ?
KekosavarAsked:
Who is Participating?
 
Bob LearnedCommented:
What does dgCustList.SelectedItem return?
0
 
KekosavarAuthor Commented:
14 hours and still no answers , nice...
0
 
Bob LearnedCommented:
Can you explain how you have this master/detail configured, please?
0
 
KekosavarAuthor Commented:
<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="DigiEcz.MusteriListe"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot">
       
        <sdk:DataGrid x:Name="dgCustList" AutoGenerateColumns="False" Background="Transparent" SelectionChanged="dgCustList_SelectionChanged">
            <sdk:DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <StackPanel>
                        <sdk:DataGrid x:Name="dgCustDetail" RowDetailsVisibilityMode="VisibleWhenSelected" AutoGenerateColumns="False"  Background="Transparent"/>
                    </StackPanel>
                </DataTemplate>
            </sdk:DataGrid.RowDetailsTemplate>
        </sdk:DataGrid>
        <Grid.Projection>
            <PlaneProjection x:Name="Projection"/>
        </Grid.Projection>
    </Grid>
</UserControl>

Its my Xaml file  and here is code behind
------------------

 public MusteriListe()
        {
            InitializeComponent();
            var stb1 = new Storyboard { Duration = new Duration(TimeSpan.FromSeconds(1)), SpeedRatio = 3 };

            var daY1 = new DoubleAnimation { From = 0.00, To = 90.00 };
            Storyboard.SetTargetName(daY1, "Projection");
            Storyboard.SetTargetProperty(daY1, new PropertyPath("RotationX"));
            stb1.Children.Add(daY1);
            this.Resources.Add("EndOfPage", stb1);

            var stb = new Storyboard();
            stb.Duration = new Duration(TimeSpan.FromSeconds(1));
            stb.SpeedRatio = 3;

            var daY = new DoubleAnimation { From = -90.00, To = 0.00 };
            Storyboard.SetTargetName(daY, "Projection");
            Storyboard.SetTargetProperty(daY, new PropertyPath("RotationX"));
            stb.Children.Add(daY);
            Resources.Add("StartOfPage", stb);

            dgCustList.Columns.Add(new DataGridTextColumn
            {
                Header = "ID",
                Binding = new Binding("CustomerID")
            });
            dgCustList.Columns.Add(new DataGridTextColumn
            {
                Header = "Müsteri Ad",
                Binding = new Binding("CustomerName")
            });
            dgCustList.Columns.Add(new DataGridTextColumn
            {
                Header = "Müsteri Soyad",
                Binding = new Binding("CustomerSurname")
            });
            dgCustList.Columns.Add(new DataGridTextColumn
            {
                Header = "Müsteri Tel",
                Binding = new Binding("CustomerPhone")
            });
            LoadGrid();
        }
        private void LoadGrid()
        {
            var client = new EczServiceClient();
            client.CustomerInfoCompleted += client_CustomerInfoCompleted;
            client.CustomerInfoAsync();
        }
        void client_CustomerInfoCompleted(object sender, CustomerInfoCompletedEventArgs e)
        {
            dgCustList.ItemsSource = e.Result;
        }

        private void dgCustList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            var customer = dgCustList.SelectedItem as CustomerInfo;
            if (customer == null) return;
            var client = new EczServiceClient();
            client.CustomerDetailCompleted += client_CustomerDetailCompleted;
            client.CustomerDetailAsync(customer.CustomerID);
        }
        void client_CustomerDetailCompleted(object sender, CustomerDetailCompletedEventArgs e)
        {
            IN HERE I WANT TO FILL DATAGRID LIKE MASTER GRID ( dgCustDetail.ItemSource = e.Result)
        }
    }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.