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*" />
<RowDefinition
Height="10*" />
<RowDefinition
Height="10*" />
<RowDefinition
Height="Auto" />
<RowDefinition
Height="40*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto"></ColumnDefinition>
<ColumnDefinition
Width="5"></ColumnDefinition>
<ColumnDefinition
Width="5*"></ColumnDefinition>
<ColumnDefinition
Width="10*"></ColumnDefinition>
<ColumnDefinition
Width="5"></ColumnDefinition>
<ColumnDefinition
Width="5*"></ColumnDefinition>
<ColumnDefinition
Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition
Height="30" />
<RowDefinition
Height="30" />
<RowDefinition
Height="30" />
</Grid.RowDefinitions>
<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>
<sdk:Label
Content="Last Name" Grid.Row="2" Grid.Column="0"
FontSize="13" FontFamily="Times New Roman" >
</sdk:Label>
<sdk:Label
Content="Email" Grid.Row="0" Grid.Column="3"
FontSize="13" FontFamily="Times New Roman"
HorizontalAlignment="Right">
</sdk:Label>
<sdk:Label
Content="Mobile" Grid.Row="1" Grid.Column="3"
FontSize="13" FontFamily="Times New Roman"
HorizontalAlignment="Right" >
</sdk:Label>
<sdk:Label
Content="Designation" Grid.Row="2" Grid.Column="3"
FontSize="13" FontFamily="Times New Roman"
HorizontalAlignment="Right">
</sdk:Label>
<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"
Style="{StaticResource
DefaultTextBoxStyle}" />
<TextBox x:Name="txtLastName" Grid.Column="2" Grid.Row="2"
Style="{StaticResource DefaultTextBoxStyle}"
/>
<TextBox x:Name="txtEmail" Grid.Column="5" Grid.Row="0"
Style="{StaticResource DefaultTextBoxStyle}"
/>
<TextBox x:Name="txtMobile" Grid.Column="5" Grid.Row="1"
Style="{StaticResource DefaultTextBoxStyle}"
/>
<TextBox x:Name="txtDesignation" Grid.Column="5" Grid.Row="2"
Style="{StaticResource DefaultTextBoxStyle}"
/>
</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" />
<sdk:DataGridTextColumn
Width="Auto" Binding="{Binding
Mode=OneWay}" Header="TravelFrom"
IsReadOnly="True" />
<sdk:DataGridTextColumn
Width="Auto" Binding="{Binding
Mode=OneWay}" Header="TravelTo"
IsReadOnly="True" />
<sdk:DataGridTextColumn
Width="Auto" Binding="{Binding
Mode=OneWay}" Header="Mode of
Travel" IsReadOnly="True" />
<sdk:DataGridTextColumn
Width="Auto" Binding="{Binding
Mode=OneWay}" Header="No. of
KM" IsReadOnly="True" />
<sdk:DataGridTextColumn
Width="Auto" Binding="{Binding
Mode=OneWay}" Header="Rate per
KM" IsReadOnly="True" />
<sdk:DataGridTextColumn
Width="Auto" Binding="{Binding
Mode=OneWay}" Header="Total Amount "
IsReadOnly="True" />
<sdk:DataGridTextColumn
Width="Auto" Binding="{Binding
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"
Grid.Row="3"
Width="200"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Text="{Binding SelectedItem.User.Remarks,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<sdk:Label Content="Amount
in words :"
Grid.Row="4"
IsRequired="True"
Foreground="Black"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Target="{Binding ElementName=txtAmountinwords}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<TextBox x:Name="txtAmountinwords"
Grid.Row="4"
Width="200"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Text="{Binding SelectedItem.User.Remarks,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<sdk:Label
Content="Approved By :"
Grid.Row="5"
IsRequired="True"
Foreground="Black"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Target="{Binding ElementName=txtApprovedBy}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<TextBox x:Name="txtApprovedBy"
Grid.Row="5"
Width="200"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Text="{Binding SelectedItem.User.Remarks,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<sdk:Label Content="Comments
:"
Grid.Row="7"
IsRequired="True"
Foreground="Black"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Target="{Binding ElementName=txtComments}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<RichTextBox
HorizontalAlignment="Right"
Name="contentBox" VerticalAlignment="Top"
Height="Auto"
Grid.Row="7"
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" />
</Grid>
</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;
};
}
#endregion
#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();
}
}
#endregion
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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
Width="789" Height="300"
Title="ConveyanceExpenses">
<Grid x:Name="LayoutRoot"
>
<Grid.RowDefinitions>
<RowDefinition
/>
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions
>
<ColumnDefinition
Width="80"></ColumnDefinition>
<ColumnDefinition
Width="5"></ColumnDefinition>
<ColumnDefinition
Width="190"></ColumnDefinition>
<ColumnDefinition
Width="5"></ColumnDefinition>
<ColumnDefinition
Width="90"></ColumnDefinition>
<ColumnDefinition
Width="5"></ColumnDefinition>
<ColumnDefinition
Width="180"></ColumnDefinition>
<ColumnDefinition
Width="5"></ColumnDefinition>
<ColumnDefinition
Width="40"></ColumnDefinition>
<ColumnDefinition
Width="5"></ColumnDefinition>
<ColumnDefinition
Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition
Height="20*"></RowDefinition>
<RowDefinition
Height="20*"></RowDefinition>
<RowDefinition
Height="20*"></RowDefinition>
</Grid.RowDefinitions>
<sdk:Label Content="Date"
Grid.Column="0"
Grid.Row="0"
IsRequired="True"
Foreground="#8A000000"
HorizontalAlignment="Right"
Target="{Binding ElementName=txtDate}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<sdk:Label Content="TravelFrom
:"
Grid.Column="0"
Grid.Row="1"
IsRequired="True"
Foreground="#8A000000"
HorizontalAlignment="Right"
Target="{Binding ElementName=txtTravelFrom}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<sdk:Label Content="TravelTo
:"
Grid.Column="0"
Grid.Row="2"
IsRequired="True"
Foreground="#8A000000"
HorizontalAlignment="Right"
Target="{Binding ElementName=txtTravelTo}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<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"
Grid.Row="1"
Width="170"
HorizontalAlignment="Left"
Text="{Binding SelectedItem.User.TravelFrom,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<TextBox x:Name="txtTravelTo"
Grid.Column="2"
Grid.Row="2"
Width="170"
HorizontalAlignment="Left"
Text="{Binding SelectedItem.User.TravelTo,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<sdk:Label Content="Mode
of Travel"
Grid.Column="4"
Grid.Row="0"
IsRequired="True"
Foreground="#8A000000"
HorizontalAlignment="Right"
Target="{Binding ElementName=txtModeOfTravel}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<sdk:Label Content="No.
of KM"
Grid.Column="4"
Grid.Row="1"
IsRequired="True"
Foreground="#8A000000"
HorizontalAlignment="Right"
Target="{Binding ElementName=txtNoofKM}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<sdk:Label Content="Rate
per KM"
Grid.Column="4"
Grid.Row="2"
IsRequired="True"
Foreground="#8A000000"
HorizontalAlignment="Right"
Target="{Binding ElementName=txtRateperKM}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<TextBox x:Name="txtModeofTravel"
Grid.Column="6"
Grid.Row="0"
Width="170"
HorizontalAlignment="Left"
Text="{Binding SelectedItem.User.ModeofTravel,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<TextBox x:Name="txtNoofKM"
Grid.Column="6"
Grid.Row="1"
Width="170"
HorizontalAlignment="Left"
Text="{Binding SelectedItem.User.NoofKM,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<TextBox x:Name="txtRatperKM"
Grid.Column="6"
Grid.Row="2"
Width="170"
HorizontalAlignment="Left"
Text="{Binding SelectedItem.User.NoofKM,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<sdk:Label Content="Total"
Grid.Column="8"
Grid.Row="0"
IsRequired="True"
Foreground="#FFA10000"
HorizontalAlignment="Left"
Target="{Binding ElementName=txtTotal}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<sdk:Label Content="Client"
Grid.Column="8"
Grid.Row="1"
IsRequired="True"
Foreground="#8A000000"
HorizontalAlignment="Left"
Target="{Binding ElementName=txtClient}"
Style="{StaticResource DefaultLabelStyle}"
FontSize="13" FontFamily="Times New Roman" />
<TextBox x:Name="txtTotal"
Grid.Column="11"
Grid.Row="0"
Width="170"
HorizontalAlignment="Left"
Text="{Binding SelectedItem.User.Total,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
<TextBox x:Name="txtClient"
Grid.Column="10"
Grid.Row="1"
Width="170"
HorizontalAlignment="Left"
Text="{Binding SelectedItem.User.Client,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True}"
Style="{StaticResource
DefaultTextBoxStyle}" />
</Grid>
<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" />
</Grid>
</controls:ChildWindow>
Child Window 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;
namespace Ifs.Client.User.View
{
public
partial class ConveyanceExpenses : ChildWindow
{
public
ConveyanceExpenses()
{
InitializeComponent();
}
private
void CANCELButton_Click(object sender, RoutedEventArgs
e)
{
this.DialogResult = false;
}
private
void SAVEButton_Click(object
sender, RoutedEventArgs e)
{
this.DialogResult = true;
}
}
}