Silverlight / WPF - Computed Columns In WPF DataGrid
Asked By krutik sheth
01-Apr-11 04:23 AM

hie,
I want to created computed columns like ms excel in wpf customized datagrid.Can anyone suggest some idea.for eg i have datagrid in following format:
<DataGrid Name="dgv" Grid.Row="1" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid Name="grdCell">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="50"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--<TextBox Name="tempTotal" Grid.Row="0" Grid.Column="0" IsReadOnly="True" Focusable="False" Visibility="Collapsed">
<TextBox.Text>
<Binding Path="tempTotal" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay"></Binding>
</TextBox.Text>
</TextBox>-->
<TextBox Name="txtDays" Grid.Row="0" Grid.Column="1" IsReadOnly="True" Focusable="False">
<TextBox.Text>
<Binding Path="days" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" ></Binding>
</TextBox.Text>
</TextBox>
<TextBox Name="txttank1" Grid.Row="0" Grid.Column="2" Background="Yellow">
<TextBox.Text>
<Binding Path="tank1" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" ></Binding>
</TextBox.Text>
</TextBox>
<TextBox Name="txttank2" Grid.Row="0" Grid.Column="3" Background="Yellow">
<TextBox.Text>
<Binding Path="tank2" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" ></Binding>
</TextBox.Text>
</TextBox>
<TextBox Name="txttank3" Grid.Row="0" Grid.Column="4" Background="Yellow">
<TextBox.Text>
<Binding Path="tank3" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" ></Binding>
</TextBox.Text>
</TextBox>
<TextBox Name="txttank4" Grid.Row="0" Grid.Column="5" Background="Yellow">
<TextBox.Text>
<Binding Path="tank4" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" ></Binding>
</TextBox.Text>
</TextBox>
<TextBox Name="txttank5" Grid.Row="0" Grid.Column="6" Background="Yellow">
<TextBox.Text>
<Binding Path="tank5" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" ></Binding>
</TextBox.Text>
</TextBox>
<TextBox Name="txttotalOilStock" Grid.Row="0" Grid.Column="7" IsReadOnly="True" Focusable="False">
<TextBox.Text>
<Binding Path="total_oil_stock" UpdateSourceTrigger="PropertyChanged" Mode="OneWay" ></Binding>
</TextBox.Text>
</TextBox>
<Button Name="btnNew" Grid.Column="8" Content="New" Click="btnNew_Click"></Button>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
there are 5 textbox with name tank1,tank2,tank3,tank4,tank5.Now what i want is in 6th textbox name total i want summation of all tank from 1 to 5.Its like i want to call text change property of each five textbox which reflect changes made in textbox named total.
Infragistics.com
Rayudu Addagarla replied to krutik sheth
Did you get answer for this if so please email how to acheive this to rayuduak AT gmail.com
ray
drag and drop row in silverlight datagrid Silverlight / WPF hi. . how to drag and drop row in silverlight datagrid? need ur suggestions with examples. . regards gopal.s Silverlight 2 Solution The first problem you will encounter in Silverlight 2 is determining how / when to initiate the drag operation. The most obvious route is
Find control in datagrid silverlight Silverlight / WPF hi. . how to find a control in datagrid. . my datatexttemplate is below <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel Orientation = "Horizontal"> <TextBlock Height name}" Tag = "{Binding name}" VerticalAlignment = "Top" / > < / StackPanel> < / DataTemplate> < / sdk:DataGridTemplateColumn.CellTemplate> < / sdk:DataGridTemplateColumn> in my datagrid i have button and when i clicked the button then i need to get the achieve this. . need ur suggtesions. . regards gopal.s Try this coding in LoadingRow event of DataGrid. void datagrid_LoadingRow( object sender, DataGridRowEventArgs e) { ComboBox cbo = datagrid.Columns[ColumnIndex].GetCellContent(e.Row) as Combobox; / / HERE CHANGE THE Combobox control with your requirement
how to acess textbox value from datagrid in wpf. . ? Silverlight / WPF hello frnds <WPF:DataGridTemplateColumn Header = "Result"> <WPF:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text = "{Binding Path = testresult}" Name = "tb" / > < / DataTemplate> < / WPF:DataGridTemplateColumn.CellTemplate> < / WPF:DataGridTemplateColumn> how to get textbox value, selected row of data grid, as shown in above
ANN: WPF DataGrid CTP .NET Framework Microsoft hat das oft vermisste WPF DataGrid Control als Open-Source CTP veröffentlicht: Blog WPF Toolkit - Preview Video DataGrid Preview & Control Investments in WPF 3.5 SP1 Codeplex WPF WPF Futures Roadmap - - Thomas Scheidegger - 'NETMaster' http: / / dnetmaster.net / C# - German Discussions Silverlight (1) DataGrid