Listview (or Datagrid) frozen totalizers in each column





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have a simple listview that displays some indicators corresponding to invest by hours. I need the last row frozen and containing each sum of its values



Here is the code that i'm using :



MainWindow.xaml:



<Window x:Class="WpfTest.MainWindow"
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:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Window.Resources>
<CollectionViewSource x:Key="ItemCollectionViewSource" CollectionViewType="ListCollectionView"/>
</Window.Resources>
<Grid>
<ListView ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.View>
<GridView>
<GridViewColumn Width="80" Header="id customer" DisplayMemberBinding="{Binding id}"/>
<GridViewColumn Width="60" Header="00 - 03 h" DisplayMemberBinding="{Binding qty_00}"/>
<GridViewColumn Width="60" Header="03 - 06 h" DisplayMemberBinding="{Binding qty_03}" />
<GridViewColumn Width="60" Header="06 - 09 h" DisplayMemberBinding="{Binding qty_06}" />
<GridViewColumn Width="60" Header="09 - 12 h" DisplayMemberBinding="{Binding qty_09}" />
<GridViewColumn Width="60" Header="12 - 15 h" DisplayMemberBinding="{Binding qty_12}" />
<GridViewColumn Width="60" Header="15 - 18 h" DisplayMemberBinding="{Binding qty_15}" />
<GridViewColumn Width="60" Header="18 - 21 h" DisplayMemberBinding="{Binding qty_18}" />
<GridViewColumn Width="60" Header="21 - 24 h" DisplayMemberBinding="{Binding qty_21}" />
<GridViewColumn Width="60" Header="Total by Id" DisplayMemberBinding="{Binding totalById}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>


Here my Invest.cs class



public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById { get; set; }
}


and the code behind:



public partial class MainWindow : Window
{
private List<Invest> investList;
public MainWindow()
{
InitializeComponent();
GetData();
CalculateTotalsById();
}
private void GetData()
{
investList = new List<Invest>();
investList.Add(new Invest() { id = "01", qty_00 = 14m, qty_03 = 10m, qty_06 = 12, qty_09 = 0 });
investList.Add(new Invest() { id = "02", qty_15 = 25m, qty_18 = 15m, qty_12 = 21 });
investList.Add(new Invest() { id = "03", qty_00 = 20m, qty_03 = 5m, qty_09 = 30 });
investList.Add(new Invest() { id = "04", qty_18 = 15m, qty_21 = 5m });
}
private void CalculateTotalsById()
{
foreach (Invest item in investList)
{
item.totalById = investList
.Where(x => x.id == item.id)
.Sum(x => x.qty_00 + x.qty_03 + x.qty_06 + x.qty_09 + x.qty_12 + x.qty_15 + x.qty_18 + x.qty_21)
;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CollectionViewSource itemCollectionViewSource;
itemCollectionViewSource = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
itemCollectionViewSource.Source = investList;
}
}


I'm currently getting the final column totals but I need a final row with the total by each row. Is it possible to have that column frozen ?



I know the next step is use any template, but I don't know the template logic at all.










share|improve this question























  • Hey. It seems there is no way to handle frozen row (Footer row) in WPF default controls. I searched some forum, where devs added additional datagrid/gridview to handle sum total. But it is very hard to manage. Personally I used Telerik GridView, where you can set footer and define aggregate functions. I hope you must try Telerik gridview. Otherwise you have to develop custom control to get required result.

    – Kamran Asim
    Jan 3 at 4:45


















0















I have a simple listview that displays some indicators corresponding to invest by hours. I need the last row frozen and containing each sum of its values



Here is the code that i'm using :



MainWindow.xaml:



<Window x:Class="WpfTest.MainWindow"
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:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Window.Resources>
<CollectionViewSource x:Key="ItemCollectionViewSource" CollectionViewType="ListCollectionView"/>
</Window.Resources>
<Grid>
<ListView ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.View>
<GridView>
<GridViewColumn Width="80" Header="id customer" DisplayMemberBinding="{Binding id}"/>
<GridViewColumn Width="60" Header="00 - 03 h" DisplayMemberBinding="{Binding qty_00}"/>
<GridViewColumn Width="60" Header="03 - 06 h" DisplayMemberBinding="{Binding qty_03}" />
<GridViewColumn Width="60" Header="06 - 09 h" DisplayMemberBinding="{Binding qty_06}" />
<GridViewColumn Width="60" Header="09 - 12 h" DisplayMemberBinding="{Binding qty_09}" />
<GridViewColumn Width="60" Header="12 - 15 h" DisplayMemberBinding="{Binding qty_12}" />
<GridViewColumn Width="60" Header="15 - 18 h" DisplayMemberBinding="{Binding qty_15}" />
<GridViewColumn Width="60" Header="18 - 21 h" DisplayMemberBinding="{Binding qty_18}" />
<GridViewColumn Width="60" Header="21 - 24 h" DisplayMemberBinding="{Binding qty_21}" />
<GridViewColumn Width="60" Header="Total by Id" DisplayMemberBinding="{Binding totalById}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>


Here my Invest.cs class



public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById { get; set; }
}


and the code behind:



public partial class MainWindow : Window
{
private List<Invest> investList;
public MainWindow()
{
InitializeComponent();
GetData();
CalculateTotalsById();
}
private void GetData()
{
investList = new List<Invest>();
investList.Add(new Invest() { id = "01", qty_00 = 14m, qty_03 = 10m, qty_06 = 12, qty_09 = 0 });
investList.Add(new Invest() { id = "02", qty_15 = 25m, qty_18 = 15m, qty_12 = 21 });
investList.Add(new Invest() { id = "03", qty_00 = 20m, qty_03 = 5m, qty_09 = 30 });
investList.Add(new Invest() { id = "04", qty_18 = 15m, qty_21 = 5m });
}
private void CalculateTotalsById()
{
foreach (Invest item in investList)
{
item.totalById = investList
.Where(x => x.id == item.id)
.Sum(x => x.qty_00 + x.qty_03 + x.qty_06 + x.qty_09 + x.qty_12 + x.qty_15 + x.qty_18 + x.qty_21)
;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CollectionViewSource itemCollectionViewSource;
itemCollectionViewSource = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
itemCollectionViewSource.Source = investList;
}
}


I'm currently getting the final column totals but I need a final row with the total by each row. Is it possible to have that column frozen ?



I know the next step is use any template, but I don't know the template logic at all.










share|improve this question























  • Hey. It seems there is no way to handle frozen row (Footer row) in WPF default controls. I searched some forum, where devs added additional datagrid/gridview to handle sum total. But it is very hard to manage. Personally I used Telerik GridView, where you can set footer and define aggregate functions. I hope you must try Telerik gridview. Otherwise you have to develop custom control to get required result.

    – Kamran Asim
    Jan 3 at 4:45














0












0








0








I have a simple listview that displays some indicators corresponding to invest by hours. I need the last row frozen and containing each sum of its values



Here is the code that i'm using :



MainWindow.xaml:



<Window x:Class="WpfTest.MainWindow"
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:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Window.Resources>
<CollectionViewSource x:Key="ItemCollectionViewSource" CollectionViewType="ListCollectionView"/>
</Window.Resources>
<Grid>
<ListView ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.View>
<GridView>
<GridViewColumn Width="80" Header="id customer" DisplayMemberBinding="{Binding id}"/>
<GridViewColumn Width="60" Header="00 - 03 h" DisplayMemberBinding="{Binding qty_00}"/>
<GridViewColumn Width="60" Header="03 - 06 h" DisplayMemberBinding="{Binding qty_03}" />
<GridViewColumn Width="60" Header="06 - 09 h" DisplayMemberBinding="{Binding qty_06}" />
<GridViewColumn Width="60" Header="09 - 12 h" DisplayMemberBinding="{Binding qty_09}" />
<GridViewColumn Width="60" Header="12 - 15 h" DisplayMemberBinding="{Binding qty_12}" />
<GridViewColumn Width="60" Header="15 - 18 h" DisplayMemberBinding="{Binding qty_15}" />
<GridViewColumn Width="60" Header="18 - 21 h" DisplayMemberBinding="{Binding qty_18}" />
<GridViewColumn Width="60" Header="21 - 24 h" DisplayMemberBinding="{Binding qty_21}" />
<GridViewColumn Width="60" Header="Total by Id" DisplayMemberBinding="{Binding totalById}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>


Here my Invest.cs class



public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById { get; set; }
}


and the code behind:



public partial class MainWindow : Window
{
private List<Invest> investList;
public MainWindow()
{
InitializeComponent();
GetData();
CalculateTotalsById();
}
private void GetData()
{
investList = new List<Invest>();
investList.Add(new Invest() { id = "01", qty_00 = 14m, qty_03 = 10m, qty_06 = 12, qty_09 = 0 });
investList.Add(new Invest() { id = "02", qty_15 = 25m, qty_18 = 15m, qty_12 = 21 });
investList.Add(new Invest() { id = "03", qty_00 = 20m, qty_03 = 5m, qty_09 = 30 });
investList.Add(new Invest() { id = "04", qty_18 = 15m, qty_21 = 5m });
}
private void CalculateTotalsById()
{
foreach (Invest item in investList)
{
item.totalById = investList
.Where(x => x.id == item.id)
.Sum(x => x.qty_00 + x.qty_03 + x.qty_06 + x.qty_09 + x.qty_12 + x.qty_15 + x.qty_18 + x.qty_21)
;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CollectionViewSource itemCollectionViewSource;
itemCollectionViewSource = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
itemCollectionViewSource.Source = investList;
}
}


I'm currently getting the final column totals but I need a final row with the total by each row. Is it possible to have that column frozen ?



I know the next step is use any template, but I don't know the template logic at all.










share|improve this question














I have a simple listview that displays some indicators corresponding to invest by hours. I need the last row frozen and containing each sum of its values



Here is the code that i'm using :



MainWindow.xaml:



<Window x:Class="WpfTest.MainWindow"
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:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Window.Resources>
<CollectionViewSource x:Key="ItemCollectionViewSource" CollectionViewType="ListCollectionView"/>
</Window.Resources>
<Grid>
<ListView ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.View>
<GridView>
<GridViewColumn Width="80" Header="id customer" DisplayMemberBinding="{Binding id}"/>
<GridViewColumn Width="60" Header="00 - 03 h" DisplayMemberBinding="{Binding qty_00}"/>
<GridViewColumn Width="60" Header="03 - 06 h" DisplayMemberBinding="{Binding qty_03}" />
<GridViewColumn Width="60" Header="06 - 09 h" DisplayMemberBinding="{Binding qty_06}" />
<GridViewColumn Width="60" Header="09 - 12 h" DisplayMemberBinding="{Binding qty_09}" />
<GridViewColumn Width="60" Header="12 - 15 h" DisplayMemberBinding="{Binding qty_12}" />
<GridViewColumn Width="60" Header="15 - 18 h" DisplayMemberBinding="{Binding qty_15}" />
<GridViewColumn Width="60" Header="18 - 21 h" DisplayMemberBinding="{Binding qty_18}" />
<GridViewColumn Width="60" Header="21 - 24 h" DisplayMemberBinding="{Binding qty_21}" />
<GridViewColumn Width="60" Header="Total by Id" DisplayMemberBinding="{Binding totalById}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>


Here my Invest.cs class



public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById { get; set; }
}


and the code behind:



public partial class MainWindow : Window
{
private List<Invest> investList;
public MainWindow()
{
InitializeComponent();
GetData();
CalculateTotalsById();
}
private void GetData()
{
investList = new List<Invest>();
investList.Add(new Invest() { id = "01", qty_00 = 14m, qty_03 = 10m, qty_06 = 12, qty_09 = 0 });
investList.Add(new Invest() { id = "02", qty_15 = 25m, qty_18 = 15m, qty_12 = 21 });
investList.Add(new Invest() { id = "03", qty_00 = 20m, qty_03 = 5m, qty_09 = 30 });
investList.Add(new Invest() { id = "04", qty_18 = 15m, qty_21 = 5m });
}
private void CalculateTotalsById()
{
foreach (Invest item in investList)
{
item.totalById = investList
.Where(x => x.id == item.id)
.Sum(x => x.qty_00 + x.qty_03 + x.qty_06 + x.qty_09 + x.qty_12 + x.qty_15 + x.qty_18 + x.qty_21)
;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CollectionViewSource itemCollectionViewSource;
itemCollectionViewSource = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
itemCollectionViewSource.Source = investList;
}
}


I'm currently getting the final column totals but I need a final row with the total by each row. Is it possible to have that column frozen ?



I know the next step is use any template, but I don't know the template logic at all.







wpf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 3:36









RubenDFCRubenDFC

104




104













  • Hey. It seems there is no way to handle frozen row (Footer row) in WPF default controls. I searched some forum, where devs added additional datagrid/gridview to handle sum total. But it is very hard to manage. Personally I used Telerik GridView, where you can set footer and define aggregate functions. I hope you must try Telerik gridview. Otherwise you have to develop custom control to get required result.

    – Kamran Asim
    Jan 3 at 4:45



















  • Hey. It seems there is no way to handle frozen row (Footer row) in WPF default controls. I searched some forum, where devs added additional datagrid/gridview to handle sum total. But it is very hard to manage. Personally I used Telerik GridView, where you can set footer and define aggregate functions. I hope you must try Telerik gridview. Otherwise you have to develop custom control to get required result.

    – Kamran Asim
    Jan 3 at 4:45

















Hey. It seems there is no way to handle frozen row (Footer row) in WPF default controls. I searched some forum, where devs added additional datagrid/gridview to handle sum total. But it is very hard to manage. Personally I used Telerik GridView, where you can set footer and define aggregate functions. I hope you must try Telerik gridview. Otherwise you have to develop custom control to get required result.

– Kamran Asim
Jan 3 at 4:45





Hey. It seems there is no way to handle frozen row (Footer row) in WPF default controls. I searched some forum, where devs added additional datagrid/gridview to handle sum total. But it is very hard to manage. Personally I used Telerik GridView, where you can set footer and define aggregate functions. I hope you must try Telerik gridview. Otherwise you have to develop custom control to get required result.

– Kamran Asim
Jan 3 at 4:45












1 Answer
1






active

oldest

votes


















0














I didn't understand exactly what you mean by frozen.



Here is an example of DataGrid (You Wrote ListView or DataGrid):



Please pay attention to the 'Total by Id' column that is ReadOnly
Xaml:



<DataGrid ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}" AutoGenerateColumns="False"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<DataGrid.Columns>
<DataGridTemplateColumn Width="60" Header="id customer" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding id}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

<DataGridTemplateColumn Width="60" Header="00 - 03 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_00}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="03 - 06 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_03}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="06 - 09 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_06}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="09 - 12 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_09}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="12 - 15 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_12}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="15 - 18 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_15}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="18 - 21 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_18}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="21 - 24 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_21}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" IsReadOnly="True" Header="Total by Id">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding totalById}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>


I also changed the DTO class inorder to support the auto increment of the row :



    public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById
{
get
{
return qty_00 + qty_03 + qty_06 + qty_09 + qty_12 + qty_15 + qty_18 + qty_21;
}

}
}


Hope it helped :)






share|improve this answer
























  • Thank you Asaf for your interest in this issue. But I must clarify the real problem. My need is to have a bottom row containing the total by each column. With the data provided this will be something as: Final row: 34, 15, 12, 30, 21, 25, 30, 5, 172 Datagrid has a property called FrozenColumnCount that allows to freeze some first columns, but I wonder if posible to freeze the last column, and to freeze the last row (the one containing the totals said above). I´m not sure if is this posible using any sort of template or dockpanel combination for this.

    – RubenDFC
    Jan 3 at 13:37











  • Hi RubenDFC, Now i understand better what you want to do :) . You may create data template but i don't recommend it - In case it will succeeded it will be a very complected one. What i will recommend is to create a wrapper object to the investList that will include another row that will contain the summery line and one of the wrapper properties will be the blinded object to the datagrid.you can add IsReadonly property to the Invest class and bind it to the IsReadOnly prop as i did in the example.

    – Asaf
    Jan 3 at 18:26












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016017%2flistview-or-datagrid-frozen-totalizers-in-each-column%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I didn't understand exactly what you mean by frozen.



Here is an example of DataGrid (You Wrote ListView or DataGrid):



Please pay attention to the 'Total by Id' column that is ReadOnly
Xaml:



<DataGrid ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}" AutoGenerateColumns="False"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<DataGrid.Columns>
<DataGridTemplateColumn Width="60" Header="id customer" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding id}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

<DataGridTemplateColumn Width="60" Header="00 - 03 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_00}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="03 - 06 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_03}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="06 - 09 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_06}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="09 - 12 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_09}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="12 - 15 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_12}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="15 - 18 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_15}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="18 - 21 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_18}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="21 - 24 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_21}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" IsReadOnly="True" Header="Total by Id">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding totalById}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>


I also changed the DTO class inorder to support the auto increment of the row :



    public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById
{
get
{
return qty_00 + qty_03 + qty_06 + qty_09 + qty_12 + qty_15 + qty_18 + qty_21;
}

}
}


Hope it helped :)






share|improve this answer
























  • Thank you Asaf for your interest in this issue. But I must clarify the real problem. My need is to have a bottom row containing the total by each column. With the data provided this will be something as: Final row: 34, 15, 12, 30, 21, 25, 30, 5, 172 Datagrid has a property called FrozenColumnCount that allows to freeze some first columns, but I wonder if posible to freeze the last column, and to freeze the last row (the one containing the totals said above). I´m not sure if is this posible using any sort of template or dockpanel combination for this.

    – RubenDFC
    Jan 3 at 13:37











  • Hi RubenDFC, Now i understand better what you want to do :) . You may create data template but i don't recommend it - In case it will succeeded it will be a very complected one. What i will recommend is to create a wrapper object to the investList that will include another row that will contain the summery line and one of the wrapper properties will be the blinded object to the datagrid.you can add IsReadonly property to the Invest class and bind it to the IsReadOnly prop as i did in the example.

    – Asaf
    Jan 3 at 18:26
















0














I didn't understand exactly what you mean by frozen.



Here is an example of DataGrid (You Wrote ListView or DataGrid):



Please pay attention to the 'Total by Id' column that is ReadOnly
Xaml:



<DataGrid ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}" AutoGenerateColumns="False"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<DataGrid.Columns>
<DataGridTemplateColumn Width="60" Header="id customer" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding id}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

<DataGridTemplateColumn Width="60" Header="00 - 03 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_00}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="03 - 06 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_03}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="06 - 09 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_06}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="09 - 12 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_09}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="12 - 15 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_12}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="15 - 18 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_15}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="18 - 21 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_18}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="21 - 24 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_21}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" IsReadOnly="True" Header="Total by Id">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding totalById}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>


I also changed the DTO class inorder to support the auto increment of the row :



    public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById
{
get
{
return qty_00 + qty_03 + qty_06 + qty_09 + qty_12 + qty_15 + qty_18 + qty_21;
}

}
}


Hope it helped :)






share|improve this answer
























  • Thank you Asaf for your interest in this issue. But I must clarify the real problem. My need is to have a bottom row containing the total by each column. With the data provided this will be something as: Final row: 34, 15, 12, 30, 21, 25, 30, 5, 172 Datagrid has a property called FrozenColumnCount that allows to freeze some first columns, but I wonder if posible to freeze the last column, and to freeze the last row (the one containing the totals said above). I´m not sure if is this posible using any sort of template or dockpanel combination for this.

    – RubenDFC
    Jan 3 at 13:37











  • Hi RubenDFC, Now i understand better what you want to do :) . You may create data template but i don't recommend it - In case it will succeeded it will be a very complected one. What i will recommend is to create a wrapper object to the investList that will include another row that will contain the summery line and one of the wrapper properties will be the blinded object to the datagrid.you can add IsReadonly property to the Invest class and bind it to the IsReadOnly prop as i did in the example.

    – Asaf
    Jan 3 at 18:26














0












0








0







I didn't understand exactly what you mean by frozen.



Here is an example of DataGrid (You Wrote ListView or DataGrid):



Please pay attention to the 'Total by Id' column that is ReadOnly
Xaml:



<DataGrid ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}" AutoGenerateColumns="False"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<DataGrid.Columns>
<DataGridTemplateColumn Width="60" Header="id customer" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding id}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

<DataGridTemplateColumn Width="60" Header="00 - 03 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_00}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="03 - 06 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_03}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="06 - 09 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_06}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="09 - 12 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_09}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="12 - 15 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_12}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="15 - 18 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_15}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="18 - 21 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_18}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="21 - 24 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_21}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" IsReadOnly="True" Header="Total by Id">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding totalById}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>


I also changed the DTO class inorder to support the auto increment of the row :



    public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById
{
get
{
return qty_00 + qty_03 + qty_06 + qty_09 + qty_12 + qty_15 + qty_18 + qty_21;
}

}
}


Hope it helped :)






share|improve this answer













I didn't understand exactly what you mean by frozen.



Here is an example of DataGrid (You Wrote ListView or DataGrid):



Please pay attention to the 'Total by Id' column that is ReadOnly
Xaml:



<DataGrid ItemsSource="{Binding Source={StaticResource ItemCollectionViewSource}}" AutoGenerateColumns="False"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<DataGrid.Columns>
<DataGridTemplateColumn Width="60" Header="id customer" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding id}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

<DataGridTemplateColumn Width="60" Header="00 - 03 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_00}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="03 - 06 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_03}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="06 - 09 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_06}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="09 - 12 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_09}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="12 - 15 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_12}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="15 - 18 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_15}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="18 - 21 h" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_18}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" Header="21 - 24 h">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding qty_21}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="60" IsReadOnly="True" Header="Total by Id">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding totalById}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>


I also changed the DTO class inorder to support the auto increment of the row :



    public class Invest
{
public string id { get; set; }
public decimal qty_00 { get; set; }
public decimal qty_03 { get; set; }
public decimal qty_06 { get; set; }
public decimal qty_09 { get; set; }
public decimal qty_12 { get; set; }
public decimal qty_15 { get; set; }
public decimal qty_18 { get; set; }
public decimal qty_21 { get; set; }
public decimal totalById
{
get
{
return qty_00 + qty_03 + qty_06 + qty_09 + qty_12 + qty_15 + qty_18 + qty_21;
}

}
}


Hope it helped :)







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 6:20









AsafAsaf

452




452













  • Thank you Asaf for your interest in this issue. But I must clarify the real problem. My need is to have a bottom row containing the total by each column. With the data provided this will be something as: Final row: 34, 15, 12, 30, 21, 25, 30, 5, 172 Datagrid has a property called FrozenColumnCount that allows to freeze some first columns, but I wonder if posible to freeze the last column, and to freeze the last row (the one containing the totals said above). I´m not sure if is this posible using any sort of template or dockpanel combination for this.

    – RubenDFC
    Jan 3 at 13:37











  • Hi RubenDFC, Now i understand better what you want to do :) . You may create data template but i don't recommend it - In case it will succeeded it will be a very complected one. What i will recommend is to create a wrapper object to the investList that will include another row that will contain the summery line and one of the wrapper properties will be the blinded object to the datagrid.you can add IsReadonly property to the Invest class and bind it to the IsReadOnly prop as i did in the example.

    – Asaf
    Jan 3 at 18:26



















  • Thank you Asaf for your interest in this issue. But I must clarify the real problem. My need is to have a bottom row containing the total by each column. With the data provided this will be something as: Final row: 34, 15, 12, 30, 21, 25, 30, 5, 172 Datagrid has a property called FrozenColumnCount that allows to freeze some first columns, but I wonder if posible to freeze the last column, and to freeze the last row (the one containing the totals said above). I´m not sure if is this posible using any sort of template or dockpanel combination for this.

    – RubenDFC
    Jan 3 at 13:37











  • Hi RubenDFC, Now i understand better what you want to do :) . You may create data template but i don't recommend it - In case it will succeeded it will be a very complected one. What i will recommend is to create a wrapper object to the investList that will include another row that will contain the summery line and one of the wrapper properties will be the blinded object to the datagrid.you can add IsReadonly property to the Invest class and bind it to the IsReadOnly prop as i did in the example.

    – Asaf
    Jan 3 at 18:26

















Thank you Asaf for your interest in this issue. But I must clarify the real problem. My need is to have a bottom row containing the total by each column. With the data provided this will be something as: Final row: 34, 15, 12, 30, 21, 25, 30, 5, 172 Datagrid has a property called FrozenColumnCount that allows to freeze some first columns, but I wonder if posible to freeze the last column, and to freeze the last row (the one containing the totals said above). I´m not sure if is this posible using any sort of template or dockpanel combination for this.

– RubenDFC
Jan 3 at 13:37





Thank you Asaf for your interest in this issue. But I must clarify the real problem. My need is to have a bottom row containing the total by each column. With the data provided this will be something as: Final row: 34, 15, 12, 30, 21, 25, 30, 5, 172 Datagrid has a property called FrozenColumnCount that allows to freeze some first columns, but I wonder if posible to freeze the last column, and to freeze the last row (the one containing the totals said above). I´m not sure if is this posible using any sort of template or dockpanel combination for this.

– RubenDFC
Jan 3 at 13:37













Hi RubenDFC, Now i understand better what you want to do :) . You may create data template but i don't recommend it - In case it will succeeded it will be a very complected one. What i will recommend is to create a wrapper object to the investList that will include another row that will contain the summery line and one of the wrapper properties will be the blinded object to the datagrid.you can add IsReadonly property to the Invest class and bind it to the IsReadOnly prop as i did in the example.

– Asaf
Jan 3 at 18:26





Hi RubenDFC, Now i understand better what you want to do :) . You may create data template but i don't recommend it - In case it will succeeded it will be a very complected one. What i will recommend is to create a wrapper object to the investList that will include another row that will contain the summery line and one of the wrapper properties will be the blinded object to the datagrid.you can add IsReadonly property to the Invest class and bind it to the IsReadOnly prop as i did in the example.

– Asaf
Jan 3 at 18:26




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016017%2flistview-or-datagrid-frozen-totalizers-in-each-column%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$