Hi,
I am Working in SilverLight5,VisualStudio 2010.Now i am detailing about my issue,i have a main page which contains Datagrid and a Hyperlinkbtn,when i am clicking the hyperlinkbtn a popup child window is comnig which contains Textboxes(the field that are in MainPage Datagrid Header).Now i want to save the text box values,means after fillng the text boxes when i will click save button i want my values to save and that values to show in main page data grid.
I am mentioning my codes also below:
Main Page:
<UserControl x:Class="Ifs.Client.User.View.LocalTravelExpenses"
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:System.WindowsControls;assembly=System.Windows.Controls"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:View="clr-namespace:Ifs.Client.User.View"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800">
<UserControl.Resources>
<View:LocalTravelExpensesViewModelHost x:Key="ViewModelDataSource"
d:IsDataSource="True" />
<DataTemplate x:Name="LocalTravelExpensesTemplate">
<TextBlock Text="{Binding Date }" />
</DataTemplate>
</UserControl.Resources>
<Border BorderBrush="DarkGray" BorderThickness="0,0,0,0" CornerRadius="80,0,80,0">
<Border.Background>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="Linen"/>
<GradientStop Color="LightSteelBlue" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="40*" />
<RowDefinition Height="10*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="5"></ColumnDefinition>
<ColumnDefinition Width="5*"></ColumnDefinition>
<ColumnDefinition Width="10*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<RowDefinition Height="30" />
<sdk:Label Content="Id" Grid.Row="0" Grid.Column="0" FontSize="13" FontFamily="Times New Roman">
</sdk:Label>
<sdk:Label Content="First Name" Grid.Row="1" Grid.Column="0" FontSize="13" FontFamily="Times New Roman">
<sdk:Label Content="Last Name" Grid.Row="2" Grid.Column="0" FontSize="13" FontFamily="Times New Roman" >
<sdk:Label Content="Email" Grid.Row="0" Grid.Column="3" FontSize="13" FontFamily="Times New Roman" HorizontalAlignment="Right">
<sdk:Label Content="Mobile" Grid.Row="1" Grid.Column="3" FontSize="13" FontFamily="Times New Roman" HorizontalAlignment="Right" >
<sdk:Label Content="Designation" Grid.Row="2" Grid.Column="3" FontSize="13" FontFamily="Times New Roman" HorizontalAlignment="Right">
<TextBox x:Name="txtId" Grid.Column="2" Grid.Row="0"
Style="{StaticResource DefaultTextBoxStyle}" />
<TextBox x:Name="txtFirstName" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Stretch"
<TextBox x:Name="txtLastName" Grid.Column="2" Grid.Row="2"
<TextBox x:Name="txtEmail" Grid.Column="5" Grid.Row="0"
<TextBox x:Name="txtMobile" Grid.Column="5" Grid.Row="1"
<TextBox x:Name="txtDesignation" Grid.Column="5" Grid.Row="2"
</Grid>
<sdk:DataGrid AutoGenerateColumns="False" Height="Auto"
HorizontalAlignment="Stretch" Name="grdLocalTravelExpenses"
VerticalAlignment="Top" Grid.Row="2" SelectionChanged="grdLocalTravelExpenses_SelectionChanged_1" FontFamily="Times New Roman" FontSize="13">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Width="Auto" Binding="{Binding
Mode=OneWay}" Header="Date" IsReadOnly="True" />
Mode=OneWay}" Header="TravelFrom" IsReadOnly="True" />
Mode=OneWay}" Header="TravelTo" IsReadOnly="True" />
Mode=OneWay}" Header="Mode of Travel" IsReadOnly="True" />
Mode=OneWay}" Header="No. of KM" IsReadOnly="True" />
Mode=OneWay}" Header="Rate per KM" IsReadOnly="True" />
Mode=OneWay}" Header="Total Amount " IsReadOnly="True" />
Mode=OneWay}" Header="Client" IsReadOnly="True" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
<sdk:Label Content="Total :"
Grid.Row="3"
IsRequired="True"
Foreground="Black"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Target="{Binding ElementName=txtTotal}"
Style="{StaticResource DefaultLabelStyle}" FontSize="13" FontFamily="Times New Roman" />
<TextBox x:Name="txtTotal"
Width="200"
HorizontalAlignment="Right"
Text="{Binding SelectedItem.User.Remarks,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
<sdk:Label Content="Amount in words :"
Grid.Row="4"
Target="{Binding ElementName=txtAmountinwords}"
<TextBox x:Name="txtAmountinwords"
<sdk:Label Content="Approved By :"
Grid.Row="5"
Target="{Binding ElementName=txtApprovedBy}"
<TextBox x:Name="txtApprovedBy"
<sdk:Label Content="Comments :"
Grid.Row="7"
Target="{Binding ElementName=txtComments}"
<RichTextBox HorizontalAlignment="Right"
Name="contentBox" VerticalAlignment="Top"
Height="Auto"
Width="390" IsReadOnly="False"
BorderThickness="3" >
<Paragraph>
VAT and Service Tax extra at actuals
Power sockets nearby the required locations to be arranged by the client.
UPS is in client scope
Ladder if required shoud be arranged by Client.
Civil Work is in Client Scope
Cabling and conduting is quoted approximately will be charged at actuals
</Paragraph>
</RichTextBox>
<Button Content="Export To Excel" Name="btnExporttoExcel" Grid.Row="7" Height="30" Width="Auto" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,106,-1,52" />
<HyperlinkButton Content="CONVEYANCE EXPENSES" Grid.Row="7" Height="25" Foreground="Black" FontSize="15" VerticalAlignment="Bottom" HorizontalAlignment="Right" x:Name="hprlnkbtnCONVEYANCEEXPENSES" Width="Auto" FontFamily="Times New Roman" FontWeight="SemiBold" Click="hprlnkbtnCONVEYANCEEXPENSES_Click" />
</Border>
</UserControl>
Main page Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Ifs.Common.Client.UI.Framework;
using System.ComponentModel.Composition;
namespace Ifs.Client.User.View
{
[ExportTask("LocalTravelExpenses",TaskType.UserManagement)]
public partial class LocalTravelExpenses : UserControl, ITaskView<LocalTravelExpensesViewModel>
#region DataMember
private LocalTravelExpensesViewModelHost ViewModelHost
get { return (LocalTravelExpensesViewModelHost)Resources["ViewModelDataSource"]; }
}
[Import]
public LocalTravelExpensesViewModel ViewModel
get { return ViewModelHost.ViewModel; }
set { ViewModelHost.ViewModel = value; }
#endregion
#region constructor
public LocalTravelExpenses()
InitializeComponent();
Loaded += (s, e) =>
grdLocalTravelExpenses.SelectionChanged += OnSelectionChanged;
};
Unloaded += (s, e) =>
grdLocalTravelExpenses.SelectionChanged -= OnSelectionChanged;
#region Method
private void OnSelectionChanged(object sender,SelectionChangedEventArgs e)
var selectedItem = grdLocalTravelExpenses.SelectedItem as LocalTravelExpenses;
public void OnUpdateViewModel(Object taskInfo)
if(ViewModel !=null)
ViewModel.OnAttach();
private void grdLocalTravelExpenses_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
private void hprlnkbtnCONVEYANCEEXPENSES_Click(object sender, RoutedEventArgs e)
ConveyanceExpenses addExpenses = new ConveyanceExpenses();
addExpenses.Show();
Child Window:
<controls:ChildWindow x:Class="Ifs.Client.User.View.ConveyanceExpenses"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Width="789" Height="300"
Title="ConveyanceExpenses">
<Grid x:Name="LayoutRoot" >
<RowDefinition />
<Grid.ColumnDefinitions >
<ColumnDefinition Width="80"></ColumnDefinition>
<ColumnDefinition Width="190"></ColumnDefinition>
<ColumnDefinition Width="90"></ColumnDefinition>
<ColumnDefinition Width="180"></ColumnDefinition>
<ColumnDefinition Width="40"></ColumnDefinition>
<RowDefinition Height="20*"></RowDefinition>
<sdk:Label Content="Date"
Grid.Column="0"
Grid.Row="0"
Foreground="#8A000000"
Target="{Binding ElementName=txtDate}"
<sdk:Label Content="TravelFrom :"
Grid.Row="1"
Target="{Binding ElementName=txtTravelFrom}"
<sdk:Label Content="TravelTo :"
Grid.Row="2"
Target="{Binding ElementName=txtTravelTo}"
<sdk:DatePicker Grid.Column="2" Height="23" HorizontalAlignment="Left" Name="datePicker1" VerticalAlignment="Center" Width="190" Background="Cornsilk" IsDropDownOpen="False" SelectedDateFormat="Short" />
<TextBox x:Name="txtTravelFrom"
Grid.Column="2"
Width="170"
Text="{Binding SelectedItem.User.TravelFrom,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
<TextBox x:Name="txtTravelTo"
Text="{Binding SelectedItem.User.TravelTo,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
<sdk:Label Content="Mode of Travel"
Grid.Column="4"
Target="{Binding ElementName=txtModeOfTravel}"
<sdk:Label Content="No. of KM"
Target="{Binding ElementName=txtNoofKM}"
<sdk:Label Content="Rate per KM"
Target="{Binding ElementName=txtRateperKM}"
<TextBox x:Name="txtModeofTravel"
Grid.Column="6"
Text="{Binding SelectedItem.User.ModeofTravel,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
<TextBox x:Name="txtNoofKM"
Text="{Binding SelectedItem.User.NoofKM,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
<TextBox x:Name="txtRatperKM"
<sdk:Label Content="Total"
Grid.Column="8"
Foreground="#FFA10000"
<sdk:Label Content="Client"
Target="{Binding ElementName=txtClient}"
Grid.Column="11"
Text="{Binding SelectedItem.User.Total,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
<TextBox x:Name="txtClient"
Grid.Column="10"
Text="{Binding SelectedItem.User.Client,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
<Button x:Name="CANCELButton" Content="CANCEL" Click="CANCELButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
<Button x:Name="SAVEButton" Content="SAVE" Click="SAVEButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
</controls:ChildWindow>
Child Window Code:
public partial class ConveyanceExpenses : ChildWindow
public ConveyanceExpenses()
private void CANCELButton_Click(object sender, RoutedEventArgs e)
this.DialogResult = false;
private void SAVEButton_Click(object sender, RoutedEventArgs e)
this.DialogResult = true;