I am currently working with a page (Vendor) a RadGridView (VendorGrid)in Silverlight 3 that has a child grid (VendorContacts) located in a radtab control. I am trying to invoke CRUD methods from a RibbonBar control located on the ParentPage (mainpage) i have achieved success with the save function when it is called from a button inside the itemdetials section of the vendor grid, however when I call the function from the parent page i am unable to get an object reference to the VendorContacts. as the only difference that I can tell is that the button includes (object sender, RoutedEventArgs e) which as far as i know are not used, i am at a loss as to what I am doing wrong.
<navigation:Page x:Class="EntityBackOffice2010_R1.VendorGridMain" |
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" |
xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" |
xmlns:grid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" |
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" |
xmlns:tnavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" |
xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" |
xmlns:telerikData="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data" |
mc:Ignorable="d" |
d:DesignWidth="1000" d:DesignHeight="600"> |
<Grid Background="Black"> |
<Border Background="Transparent" BorderBrush="#7FFFFFFF" BorderThickness="1" CornerRadius="3" Margin="3"> |
<Grid Background="#FFD7E1E4"> |
<Grid.RowDefinitions> |
<RowDefinition /> |
</Grid.RowDefinitions> |
<grid:RadGridView Grid.Row="0" |
x:Name="VendorGrid" |
ItemsSource="{Binding}" |
Background="Transparent" |
AlternationCount="2" |
AlternateRowBackground="#FFE1E6E3" |
Margin="5" |
RowDetailsVisibilityMode="VisibleWhenSelected" |
AddingNewDataItem="VendorGrid_AddingNewDataItem" |
RowEditEnded="VendorGrid_RowEditEnded" |
ColumnWidth="*" |
DataLoadMode="Asynchronous" |
IsReadOnly="False" |
AutoGenerateColumns="False" |
CanUserFreezeColumns="False" |
CanUserResizeColumns="False" |
CanUserDeleteRows="False" |
CanUserInsertRows="True" |
ShowGroupFooters="False" |
ShowGroupPanel="False" |
RowIndicatorVisibility="Collapsed"> |
<grid:RadGridView.Columns> |
<grid:GridViewDataColumn Header="ID" DataMemberBinding="{Binding VendorID}" IsReadOnly="True" /> |
<grid:GridViewDataColumn Header="Company Name" DataMemberBinding="{Binding VendorName, Mode=TwoWay}" IsReadOnly="True" /> |
<grid:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description, Mode=TwoWay}" Width="*" IsReadOnly="True" /> |
<grid:GridViewDataColumn Header="Manager" DataMemberBinding="{Binding Manager, Mode=TwoWay}" IsReadOnly="True" /> |
<grid:GridViewDataColumn Header="City" DataMemberBinding="{Binding PCity, Mode=TwoWay}" IsReadOnly="True" /> |
<grid:GridViewDataColumn Header="State" DataMemberBinding="{Binding PState, Mode=TwoWay}" IsReadOnly="True" /> |
<grid:GridViewDataColumn Header="Phone" DataMemberBinding="{Binding Phone, Mode=TwoWay}" IsReadOnly="True"/> |
</grid:RadGridView.Columns> |
<grid:RadGridView.RowDetailsTemplate> |
<DataTemplate x:Name="VendorDetailsTemplate"> |
<StackPanel Orientation="Vertical" Margin="0" Grid.Row="0"> |
<tnavigation:RadTabControl x:Name="VendorDetailsTemplateTabCTRL" BackgroundVisibility="Visible" Margin="0,0,0,0" VerticalAlignment="Top" Background="Transparent" controls:StyleManager.Theme="Office_Black"> |
<tnavigation:RadTabItem Header="Contacts"> |
<Border BorderBrush="#FF848484" BorderThickness="0,1,0,0"> |
<grid:RadGridView |
x:Name="VendorContactsGrid" |
DataContext="{x:Null}" |
ShowGroupPanel="False" |
Margin="15" |
Loaded="VendorContacts_Loaded" |
AutoGenerateColumns="False"> |
<grid:RadGridView.Columns> |
<grid:GridViewDataColumn Header="Title" DataMemberBinding="{Binding Title, Mode=TwoWay}"/> |
<grid:GridViewDataColumn Header="FirstName" DataMemberBinding="{Binding FirstName, Mode=TwoWay}" /> |
<grid:GridViewDataColumn Header="LastName" DataMemberBinding="{Binding LastName, Mode=TwoWay}"/> |
<grid:GridViewDataColumn Header="Phone" DataMemberBinding="{Binding Phone, Mode=TwoWay}"/> |
<grid:GridViewDataColumn Header="Fax" DataMemberBinding="{Binding Fax, Mode=TwoWay}"/> |
<grid:GridViewDataColumn Header="Email" DataMemberBinding="{Binding Email, Mode=TwoWay}"/> |
<grid:GridViewDataColumn Header="Active" DataMemberBinding="{Binding Active, Mode=TwoWay}"/> |
</grid:RadGridView.Columns> |
</grid:RadGridView> |
</Border> |
</tnavigation:RadTabItem> |
</tnavigation:RadTabControl> |
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2" Margin="5,5,5,5" HorizontalAlignment="Right"> |
<controls:RadButton Height="25" Margin="5" Content="NEW" Click="addVendorBtn_Click" FontSize="10" Width="75" controls:StyleManager.Theme="Office_Black"/> |
<controls:RadButton Height="25" Margin="5" Content="SAVE" Click="saveVendorChanges_Click" FontSize="10" Width="75" controls:StyleManager.Theme="Office_Black"/> |
<controls:RadButton Height="25" Margin="5" Content="DELETE" FontSize="10" Width="75" controls:StyleManager.Theme="Office_Black"/> |
<controls:RadButton Height="25" Margin="5" Content="CANCEL" FontSize="10" Width="75" controls:StyleManager.Theme="Office_Black"/> |
</StackPanel> |
</StackPanel> |
</DataTemplate> |
</grid:RadGridView.RowDetailsTemplate> |
</grid:RadGridView> |
</Grid> |
</Border> |
</Grid> |
</navigation:Page> |
//Called from Parent RibbonBar |
public void saveVendor() |
{ |
Vendor v = this.VendorGrid.SelectedItem as Vendor; |
VendorContact vc = this.VendorContactsGrid.CurrentItem as VendorContact; |
svcContext.UpdateObject(v); |
svcContext.UpdateObject(vc); |
svcContext.BeginSaveChanges(SaveChangesOptions.Batch, OnVendorChangesSaved, v); |
} |
//Called from Button in ItemDetails of VendorGrid |
public void saveVendorChanges_Click(object sender, RoutedEventArgs e) |
{ |
Vendor v = this.VendorGrid.SelectedItem as Vendor; |
VendorContact vc = VendorContactsGrid.CurrentItem as VendorContact; |
svcContext.UpdateObject(v); |
svcContext.UpdateObject(vc); |
svcContext.BeginSaveChanges(SaveChangesOptions.Batch, OnVendorChangesSaved, v); |
} |