Summary and detail in listbox
A couple of posts back we saw how to create a simple yet functional expander control. this sample shows how to use one of those in listbox. we will replace the listboxitem template with our expander control.
see a demo
source is available here

Your sample doesn’t work with non-english system locale settings. Just try to change Decimal symbol to comma for example (russian format: decimal symbol is comma, digit grouping symbol is space).
—————————
Windows Internet Explorer
—————————
Silverlight error message
ErrorCode: 4002
ErrorType: ManagedRuntimeError
Message: System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Decimal.Parse(String s)
at slapp1.Page.b__4(Customer l)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.Sum(IEnumerable`1 source)
at slapp1.Page.Page_Loaded(Object sender, RoutedEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
—————————
OK
—————————
Oldlaurel
April 15, 2008
Hi,
Do you know how to fix it. I will make the change
lee
April 15, 2008
Just change
decimal total = (from l in li select Decimal.Parse(l.Total)).Sum();
to
decimal total = (from l in li select Decimal.Parse(l.Total, System.Globalization.CultureInfo.InvariantCulture)).Sum();
in Page.xaml.cs
Oldlaurel
April 15, 2008
Thanks Oldlaurel, updated the code
lee
April 15, 2008
very nice.
any chance of doing it in VB
GJ
May 11, 2008
GJ,
I did not do vb in sometime. I will give it a shot, but might take some time, did you try c# to vb converters(this might be faster)
lee
May 12, 2008