Kekosavar
asked on
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 ?
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 ?
Can you explain how you have this master/detail configured, please?
ASKER
<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="DigiEcz.MusteriLi ste"
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="dgCustLi st_Selecti onChanged" >
<sdk:DataGrid.RowDetailsTe mplate>
<DataTemplate>
<StackPanel>
<sdk:DataGrid x:Name="dgCustDetail" RowDetailsVisibilityMode=" VisibleWhe nSelected" AutoGenerateColumns="False " Background="Transparent"/>
</StackPanel>
</DataTemplate>
</sdk:DataGrid.RowDetailsT emplate>
</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.FromSeco nds(1)), SpeedRatio = 3 };
var daY1 = new DoubleAnimation { From = 0.00, To = 90.00 };
Storyboard.SetTargetName(d aY1, "Projection");
Storyboard.SetTargetProper ty(daY1, new PropertyPath("RotationX")) ;
stb1.Children.Add(daY1);
this.Resources.Add("EndOfP age", stb1);
var stb = new Storyboard();
stb.Duration = new Duration(TimeSpan.FromSeco nds(1));
stb.SpeedRatio = 3;
var daY = new DoubleAnimation { From = -90.00, To = 0.00 };
Storyboard.SetTargetName(d aY, "Projection");
Storyboard.SetTargetProper ty(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.CustomerInfoComplet ed += client_CustomerInfoComplet ed;
client.CustomerInfoAsync() ;
}
void client_CustomerInfoComplet ed(object sender, CustomerInfoCompletedEvent Args e)
{
dgCustList.ItemsSource = e.Result;
}
private void dgCustList_SelectionChange d(object sender, SelectionChangedEventArgs e)
{
var customer = dgCustList.SelectedItem as CustomerInfo;
if (customer == null) return;
var client = new EczServiceClient();
client.CustomerDetailCompl eted += client_CustomerDetailCompl eted;
client.CustomerDetailAsync (customer. CustomerID );
}
void client_CustomerDetailCompl eted(objec t sender, CustomerDetailCompletedEve ntArgs e)
{
IN HERE I WANT TO FILL DATAGRID LIKE MASTER GRID ( dgCustDetail.ItemSource = e.Result)
}
}
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
<sdk:DataGrid.RowDetailsTe
<DataTemplate>
<StackPanel>
<sdk:DataGrid x:Name="dgCustDetail" RowDetailsVisibilityMode="
</StackPanel>
</DataTemplate>
</sdk:DataGrid.RowDetailsT
</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.FromSeco
var daY1 = new DoubleAnimation { From = 0.00, To = 90.00 };
Storyboard.SetTargetName(d
Storyboard.SetTargetProper
stb1.Children.Add(daY1);
this.Resources.Add("EndOfP
var stb = new Storyboard();
stb.Duration = new Duration(TimeSpan.FromSeco
stb.SpeedRatio = 3;
var daY = new DoubleAnimation { From = -90.00, To = 0.00 };
Storyboard.SetTargetName(d
Storyboard.SetTargetProper
stb.Children.Add(daY);
Resources.Add("StartOfPage
dgCustList.Columns.Add(new
{
Header = "ID",
Binding = new Binding("CustomerID")
});
dgCustList.Columns.Add(new
{
Header = "Müsteri Ad",
Binding = new Binding("CustomerName")
});
dgCustList.Columns.Add(new
{
Header = "Müsteri Soyad",
Binding = new Binding("CustomerSurname")
});
dgCustList.Columns.Add(new
{
Header = "Müsteri Tel",
Binding = new Binding("CustomerPhone")
});
LoadGrid();
}
private void LoadGrid()
{
var client = new EczServiceClient();
client.CustomerInfoComplet
client.CustomerInfoAsync()
}
void client_CustomerInfoComplet
{
dgCustList.ItemsSource = e.Result;
}
private void dgCustList_SelectionChange
{
var customer = dgCustList.SelectedItem as CustomerInfo;
if (customer == null) return;
var client = new EczServiceClient();
client.CustomerDetailCompl
client.CustomerDetailAsync
}
void client_CustomerDetailCompl
{
IN HERE I WANT TO FILL DATAGRID LIKE MASTER GRID ( dgCustDetail.ItemSource = e.Result)
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER