/// <summary>
/// The main application class.
/// </summary>
public
partial
class
App
{
#region Constructor
/// <summary>
/// Initializes a new instance of <see cref="App" />.
/// </summary>
public
App()
{
StyleManager.ApplicationTheme =
new
Windows8Theme();
InitializeComponent();
Windows8Palette.Palette.AccentColor = (Color)Resources[
"AccentColor"
];
ConfigureCulture();
}
#endregion
#region Private Methods
/// <summary>
/// Configures the culture for the application.
/// </summary>
private
static
void
ConfigureCulture()
{
// set the default culture to English (AU)
// ReSharper disable UseObjectOrCollectionInitializer
var culture =
new
CultureInfo(
"en-AU"
);
// ReSharper restore UseObjectOrCollectionInitializer
// long date format is used on date controls ("D")
culture.DateTimeFormat.LongDatePattern = "ddd d-MMM-yyyy";
// short date format is used in grids ("d")
culture.DateTimeFormat.ShortDatePattern = "dd-MMM-yy";
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
#endregion
}
<
telerikDocking:RadSplitContainer
Orientation
=
"Horizontal"
InitialPosition
=
"DockedBottom"
>
<
telerikDocking:RadPaneGroup
>
<!-- Modification Pane -->
<
TAS2DockingPanes:ModificationsPane
x:Name
=
"radPaneModifications"
CanUserClose
=
"False"
CanDockInDocumentHost
=
"False"
IsHidden
=
"{Binding Source={x:Static TAS2DockingPanes:VisibilitySettings.Instance}, Path=CanViewModificationsPane, Converter={StaticResource boolToReverseConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
<!-- Pricing Pane -->
<
TAS2DockingPanes:ExtrasPricingPane
x:Name
=
"radPanePricingExtras"
CanUserClose
=
"False"
CanDockInDocumentHost
=
"False"
IsHidden
=
"{Binding Source={x:Static TAS2DockingPanes:VisibilitySettings.Instance}, Path=CanViewExtrasPricingPane, Converter={StaticResource boolToReverseConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
</
telerikDocking:RadPaneGroup
>
</
telerikDocking:RadSplitContainer
>
public class VisibilitySettings : INotifyPropertyChanged
{
private static readonly VisibilitySettings instance = new VisibilitySettings();
private VisibilitySettings() { }
public static VisibilitySettings Instance
{
get
{
return instance;
}
}
private static bool m_canViewExtrasPricingPane;
private static bool m_canViewModificationsPane;
public static void SetVisibilitySettings(bool canViewExtrasPricingPane, bool canViewModificationsPane)
{
Instance.CanViewExtrasPricingPane = canViewExtrasPricingPane;
Instance.CanViewModificationsPane = canViewModificationsPane;
}
public bool CanViewExtrasPricingPane
{
get
{
return m_canViewExtrasPricingPane;
}
set
{
m_canViewExtrasPricingPane = value;
OnPropertyChanged(new PropertyChangedEventArgs("CanViewExtrasPricingPane"));
}
}
public bool CanViewModificationsPane
{
get
{
return m_canViewModificationsPane;
}
set
{
m_canViewModificationsPane = value;
OnPropertyChanged(new PropertyChangedEventArgs("CanViewModificationsPane"));
}
}
//INotifyPropertyChanged Event
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
PropertyChanged(this, e);
}
}
Hi
I am creating AggregateFunctions code-behind (see example code below). The CountFunction works but when I include a SumFunction the program crashes with the following error:
No generic method 'Sum' on type
'System.Linq.Enumerable' is compatible with the supplied type arguments. No type argiuments should be provided if the method is non-generic.
I can only see two possible explanations:
1. I am not setting the AggregateFunction properties correctly.
2. Setting Grid.ItemsSource to ObservableCollection<dynamic>
This collections data is correct since is working correctly when not using AggregateFunctions.
Is a dynamically created class a problem? The actual class properties are not dynamic but the actual system data types.
I am also using Grouping and it also works correctly. To make sure that grouping was not the problem I eliminated the grouping but the program still crashes.
---- The following is being looped ----
GridViewDataColumn dataCol = new GridViewDataColumn();
dataCol.DataMemberBinding = new Binding(column.ColumnName);
dataCol.Header = column.ColumnName;
dataCol.UniqueName = column.ColumnName;
dataCol.DataType = Type.GetType(column.SystemDataType);
dataCol.FilterMemberType = Type.GetType(column.SystemDataType);
--- Hard coded to test AggregateFunctions
if (dataCol.UniqueName == "Uid")
{
SumFunction sumFunction = new SumFunction();
sumFunction.SourceField = "Uid";
sumFunction.ResultFormatString = "Tot Uid: {0}";
sumFunction.SourceFieldType = Type.GetType(column.SystemDataType); // System.Int32
dataCol.AggregateFunctions.Add(sumFunction);
}
--- End hard coding ---
grid.Columns.Add(dataCol);
---- End of Loop ----
grid.ShowColumnFooters = true;
grid.ShowGroupFooters = true;
grid.ItemsSource = new QueryableCollectionView(clientData.Result);
Crashed at this point setting the ItemsSource.
Before putting in the SumFunction code everything was working correctly!
clientData.Result is ObservableCollection<dynamic>
====================================
If you don't have the answer could you provide the code-behind to create AggregrateFunctions. The following xaml snippet is from the WPF example Aggregates which is under the Grouping and Aggregates category. In looking at numerous past posts of this problem I think it would be most helpful to many developers to take the aggregate example and define the grid properties in code-behind. I would like to see a AggregateFunctions example that works using code-behind.
Thanks
Rich
<telerik:GridViewDataColumn Header="Freight"
DataMemberBinding="{Binding Freight, StringFormat=c}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction SourceField="Freight" ResultFormatString="Total: {0:c}" />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>