Hi @All,
as far as I could see from the samples the Telerik UI for WPF components are mainly targeted towards an WCF-based backend service.
Is it easily possible to use a ASP.NET MVC WebAPI REST-service as a backend from a WPF Desktop application?
I'd like to build a SPA web app that uses MCV Web API as a backend. There is also a mobile app that uses the same REST-services. But for some functions the browser is not a good platform and I'd like to give our users a "fat-client" (e.g. for report design, Office ole-automation). But I'd also like to use the same backend for both and I wouldn't like to build a new WCF-backend only for the desktop clients. Of course the WPF application should be full-featured (data grids, data filters) and I don't want to re-invent the wheel.
Are there any samples available for this scenario?
Kind regards
Gerold
Hello,
I'm writing a custom filter for a RadGridView and it works almost perfectly.
The only problem I have is that I am calling GetDistinctValues(ColumnToPrepare, True, Nil) on the IFilterDescriptor.Prepare method, in order to know which values I must display. During the call to GetDistinctValues, the GridView runtime calls the filter expression to filter the items.
From the documentation, it seems that this overload of GetDistinctValues should filter the items with other filters, but not the one on the current column. Is there an error in the documentation or an error in the code?
Note that I've currently curcumvent the problem by using a field to "disable" my filter in this case, but it is not a "clean" solution.
I have experienced an error in RadCalendar where the years displayed are wrong, after navigating outwards from the current month to the current year and then again to the current decade and out to the current century and moving back and forth. The Text property is not dislaying the CalendarButtonContent Date. Why this happens is not something I am sure, but I set the Culture of the calendar to Norwegian bokmål (nb-no). Let me show you how at least I managed to get the RadCalendar working again.
First off in your resource file, define a style for the RadCalendar:
<Style TargetType="{x:Type telerikInput:RadCalendar}"><Setter Property="FontFamily" Value="Segoe UI" /><Setter Property="FontSize" Value="9" /> <EventSetter Event="Loaded" Handler="RadCalendar_Loaded" /></Style>
The style got no key, so it will be the implicit style of any RadCalendar control/instance in your app. Ok, so now let's look at the EventSetter.
public void RadCalendar_Loaded(object sender, EventArgs e)
{
try {
var radCalendar = sender as RadCalendar;
if (radCalendar != null)
{
radCalendar.Culture = new CultureInfo("nb-NO");
radCalendar.DisplayModeChanged += radCalendar_DisplayModeChanged;
radCalendar.DisplayDateChanged += radCalendar_DisplayDateChanged;
}
}
catch (Exception) { }
}
void radCalendar_DisplayDateChanged(object sender, Telerik.Windows.Controls.Calendar.CalendarDateChangedEventArgs e)
{
AdjustRadCalendarDisplayYearsFix(sender);
}
void radCalendar_DisplayModeChanged(object sender, Telerik.Windows.Controls.Calendar.CalendarModeChangedEventArgs e)
{
AdjustRadCalendarDisplayYearsFix(sender);
}
private static void AdjustRadCalendarDisplayYearsFix(object sender)
{
//TA 11.11.2015: Resolution of the calendar bug observed when navigating years and decades in the calendar var calendar = sender as RadCalendar;
if (calendar == null)
return;
DispatcherUtil.DelayedInvokeAction(() =>
{
var calendarButtons = calendar.ChildrenOfType<CalendarButton>().ToList();
if (calendarButtons.Any())
{
foreach (var c in calendarButtons.Where(cb => cb.ButtonType == CalendarButtonType.Year || cb.ButtonType == CalendarButtonType.Decade))
{
try {
if (c.DataContext is CalendarButtonContent)
{
var cbc = c.DataContext as CalendarButtonContent;
var tb = c.FindChildByType<TextBlock>();
if (tb != null)
tb.Text = cbc.ButtonType == CalendarButtonType.Year ? cbc.Date.ToString("yyyy") :
cbc.Date.ToString("yyyy") + "-" + cbc.Date.AddYears(10).ToString("yy");
}
}
catch (Exception err)
{
Debug.WriteLine(err.Message);
}
}
}
}, 500);
}
Ok, so we also use something called DelayedInvokeAction here:
/// <summary> /// Executes an action passed into this method by a timeout measured in milliseconds /// </summary> /// <param name="executeAction">Action to execute</param> /// <param name="timeOut">The timeout to wait before executing (in milliseconds)</param> /// <param name="priority"></param> /// /// <param name="keyToken">A key token to identity the switch (basic grouing). Will be used as a tag on the DispatcherTimer</param> public static bool DelayedInvokeAction(Action executeAction, int timeOut, DispatcherPriority priority = DispatcherPriority.Background, Guid? keyToken = null)
{
var delayedAction = new DelayedAction(executeAction, timeOut, keyToken);
ActionsRegistered.Add(delayedAction);
DispatcherTimer dtimer = new DispatcherTimer(priority);
dtimer.Interval += new TimeSpan(0, 0, 0, 0, timeOut);
dtimer.Tag = delayedAction.ExecuteGuid;
dtimer.Tick += DelayedInvokeTimerTick;
dtimer.IsEnabled = true;
dtimer.Start();
return true;
}
public class DelayedAction {
private readonly Action actionToExecute;
private readonly int timeOut;
private readonly Guid executeGuid;
public Action ActionToExecute
{
get { return actionToExecute; }
}
public int TimeOut
{
get { return timeOut; }
}
public Guid ExecuteGuid
{
get { return executeGuid; }
}
public DelayedAction(Action actionToExecute, int timeOut, Guid? keytoken)
{
this.actionToExecute = actionToExecute;
this.timeOut = timeOut;
this.executeGuid = keytoken ?? Guid.NewGuid();
}
}
Hope this helps!
Dear Team,
I am using the docking custom property provider to save the state of my layout. When i reload the layout i can able to load the three different radpane in the specified position but data is not loading. please help to check and advise on this issue.
<
Grid
>
<
Grid
Opacity
=
"{Binding MainGridOpacity}"
>
<
telerik:RadDocking
x:Name
=
"radDocking"
HasDocumentHost
=
"False"
>
<
telerik:RadDocking.DocumentHost
>
<
telerik:RadSplitContainer
ScrollViewer.VerticalScrollBarVisibility
=
"Auto"
>
<
telerik:RadSplitContainer
Orientation
=
"Vertical"
telerik:ProportionalStackPanel.RelativeSize
=
"70, 100"
>
<
telerik:RadPaneGroup
>
<
telerik:RadPane
x:Name
=
"radPane1"
Header
=
"Dashboard"
telerik:RadDocking.SerializationTag
=
"radPane1"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
StackPanel
>
<
telerik:RadTabControl
Width
=
"Auto"
VerticalAlignment
=
"Stretch"
x:Name
=
"radDashboardTabControl"
>
</
telerik:RadTabControl
>
</
StackPanel
>
</
Grid
>
</
telerik:RadPane
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
<
telerik:RadSplitContainer
Orientation
=
"Vertical"
InitialPosition
=
"DockedRight"
telerik:ProportionalStackPanel.RelativeSize
=
"30, 100"
>
<
telerik:RadSplitContainer
Orientation
=
"Horizontal"
>
<
telerik:RadPaneGroup
telerik:ProportionalStackPanel.RelativeSize
=
"50, 50"
>
<
telerik:RadPane
Header
=
"ApplicationInfo"
telerik:RadDocking.SerializationTag
=
"ApplicationInfo"
>
<!--<ScrollViewer VerticalScrollBarVisibility="Auto">-->
<
StackPanel
>
<
TextBlock
Text
=
"{Binding AppNo}"
/>
<
ContentControl
x:Name
=
"appInfoControl"
/>
</
StackPanel
>
<!--</ScrollViewer>-->
</
telerik:RadPane
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
<
telerik:RadSplitContainer
Orientation
=
"Horizontal"
>
<
telerik:RadPaneGroup
x:Name
=
"radPaneGroup1"
telerik:ProportionalStackPanel.RelativeSize
=
"50, 50"
>
<
telerik:RadPane
x:Name
=
"radPane11"
Header
=
"WorkLoad"
telerik:RadDocking.SerializationTag
=
"radPane11"
>
<
ScrollViewer
Visibility
=
"Visible"
HorizontalScrollBarVisibility
=
"Visible"
>
<
ContentControl
x:Name
=
"workLoadControl"
/>
</
ScrollViewer
>
</
telerik:RadPane
>
</
telerik:RadPaneGroup
>
</
telerik:RadSplitContainer
>
</
telerik:RadSplitContainer
>
</
telerik:RadSplitContainer
>
</
telerik:RadDocking.DocumentHost
>
</
telerik:RadDocking
>
</
Grid
>
<
Grid
>
<
StackPanel
Margin
=
"3"
>
<
telerik:RadButton
Margin
=
"0 2"
Width
=
"200"
Content
=
"Save Layout"
Click
=
"OnSave"
x:Name
=
"buttonSave"
/>
<
telerik:RadButton
Margin
=
"0 2"
Width
=
"200"
Content
=
"Load Layout"
Click
=
"OnLoad"
x:Name
=
"buttonLoad"
/>
</
StackPanel
>
</
Grid
>
</
Grid
>
public
partial
class
DashboardGridView : UserControl
{
System.IO.Stream stream;
public
DashboardGridView()
{
ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(
typeof
(Telerik.Windows.Controls.RadDocking),
new
DockingCustomPropertyProvider());
}
private
void
OnSave(
object
sender, System.Windows.RoutedEventArgs e)
{
PersistenceManager manager =
new
PersistenceManager();
this
.stream = manager.Save(
this
.radDocking);
this
.EnsureLoadState();
using
(FileStream file =
new
FileStream(@
"C:\temp\file.bin"
, FileMode.Create, System.IO.FileAccess.Write))
{
byte
[] bytes =
new
byte
[stream.Length];
stream.Read(bytes, 0, (
int
)stream.Length);
file.Write(bytes, 0, bytes.Length);
stream.Close();
}
}
private
void
OnLoad(
object
sender, System.Windows.RoutedEventArgs e)
{
using
(stream =
new
MemoryStream())
{
using
(FileStream file =
new
FileStream(@
"C:\temp\file.bin"
, FileMode.Open, FileAccess.Read))
{
byte
[] bytes =
new
byte
[file.Length];
file.Read(bytes, 0, (
int
)file.Length);
stream.Write(bytes, 0, (
int
)file.Length);
}
this
.stream.Position = 0L;
PersistenceManager manager =
new
PersistenceManager();
manager.Load(
this
.radDocking,
this
.stream);
this
.EnsureLoadState();
}
}
private
bool
CanLoad()
{
return
this
.stream !=
null
&&
this
.stream.Length > 0;
}
private
void
EnsureLoadState()
{
this
.buttonLoad.IsEnabled =
this
.CanLoad();
}
}
This is urgent since I can't do anything else on my WPF app until this gets figured out!
I was trying to add a RadCartesianChart on an existing WPF project and I was having the following error message on the designer view(even though it would compile and run normally):
[System.InvalidOperationException
Sequence contains more than one element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineGenericParameters(Type type, MockTypeDefinition mockType)
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.MockGenericType(Type type)
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineProperty(TypeDefinition typeDefinition, PropertyInfo propertyInfo)....]
I tried a bunch of different things and the error remained, so I decided to create a new WPF project and paste some code from the RadChartView - Getting Started topic on http://docs.telerik.com/ and then I got
[System.NullReferenceException
Object reference not set to an instance of an object.
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeDefinition.ImplementAbstractEvent(EventDefinition eventDefinition, Boolean shouldOverride, Action`3 emitAddMethodBody, Action`3 emitRemoveMethodBody)
at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.InterfaceEmitterFactory.DefaultInterfaceEmitter.ImplementEvent(EventDefinition eventDefinition, Boolean shouldOverride)...]
I don't know if it helps but I attached an image of what the error looks like on the second case.
Hi,
I use INotifyLocationChanged to raise event when items of a VisualizationLayer move and it throws an exception in some particular case. I've joined a sample project that demonstrate this particular case. I'm I doing something wrong or this is a bug ?
Thank you,
Etienne
Hi,
I've implemented the ScheduleView via my own models implementing the IAppointment interface.
In the normal Week view everything works fine, but as soon as I add a grouped view to the ScheduleView no appointments are displayed (although they are correctly loaded in the viewmodel).
The XAML I add:
<telerik:RadScheduleView.GroupDescriptionsSource>
<telerik:GroupDescriptionCollection>
<telerik:ResourceGroupDescription ResourceType="Mitarbeiter"/>
<telerik:DateGroupDescription />
</telerik:GroupDescriptionCollection>
</telerik:RadScheduleView.GroupDescriptionsSource>
Any suggestion what I'm doing wrong?
thx
I'm new to this so I'm hoping to find some direction. I have a plot on in a RadCartesianChart. I want to be able to right-click and capture the location of the mouse at that place. Before we had a double click mouse event and were able to do this:
1.
private
void
ChartSelectionBehavior_SelectionChanged(
object
sender, Telerik.Windows.Controls.ChartView.ChartSelectionChangedEventArgs e)
2.
{
3.
if
(e.AddedPoints.Count > 0)
4.
{
5.
ViewModel.NotePoint = e.AddedPoints[0].DataItem
as
GraphPlots;
6.
}
7.
}
Now I have this:
private
void
standardGraph_MouseRightButtonUp(
object
sender, System.Windows.Input.MouseButtonEventArgs e)
{
//I want to set the NotePoint of the View Model to the location
//of the right-mouse click here
plotContextMenu.Visibility = System.Windows.Visibility.Visible;
}
I can get the location of the MouseButtonEvent, but once I do I'm not sure how to set it as a GraphPlot.
Here's my XML:
01.
<
telerik:RadCartesianChart
Visibility
=
"{Binding StdGraphVisibility}"
02.
x:Name
=
"standardGraph"
03.
Height
=
"500"
04.
Width
=
"1000"
05.
MouseRightButtonDown
=
"mouseRightButtonDown"
06.
MouseRightButtonUp
=
"standardGraph_MouseRightButtonUp"
>
07.
08.
<
telerik:RadContextMenu.ContextMenu
>
09.
10.
<
telerik:RadContextMenu
x:Name
=
"plotContextMenu"
11.
Visibility
=
"Hidden"
>
12.
13.
<
telerik:RadMenuItem
Header
=
"Add note"
14.
x:Name
=
"addNoteMenuItem"
15.
Click
=
"addNoteMenuItem_Click"
/>
16.
17.
</
telerik:RadContextMenu
>
18.
</
telerik:RadContextMenu.ContextMenu
>
19.
20.
<
telerik:RadCartesianChart.Behaviors
>
21.
22.
<
telerik:ChartSelectionBehavior
DataPointSelectionMode
=
"Single"
23.
SelectionChanged
=
"ChartSelectionBehavior_SelectionChanged"
/>
24.
25.
</
telerik:RadCartesianChart.Behaviors
>
26.
27.
<
telerik:RadCartesianChart.HorizontalAxis
>
28.
</
telerik:RadCartesianChart.HorizontalAxis
>
29.
30.
<
telerik:RadCartesianChart.VerticalAxis
>
31.
</
telerik:RadCartesianChart.VerticalAxis
>
32.
33.
<
telerik:RadCartesianChart.Grid
>
34.
35.
<
chartView:CartesianChartGrid
MajorLinesVisibility
=
"Y"
StripLinesVisibility
=
"Y"
/>
36.
37.
</
telerik:RadCartesianChart.Grid
>
38.
39.
<
telerik:RadCartesianChart.Series
>
40.
<
telerik:LineSeries
Stroke
=
"Orange"
41.
CategoryBinding
=
"Category"
42.
ValueBinding
=
"Value"
43.
ItemsSource
=
"{Binding GraphValue}"
>
44.
</
telerik:LineSeries
>
45.
46.
<
telerik:PointSeries
CategoryBinding
=
"Category"
47.
ValueBinding
=
"Value"
48.
ItemsSource
=
"{Binding Notes}"
>
49.
</
telerik:PointSeries
>
50.
</
telerik:RadCartesianChart.Series
>
51.
</
telerik:RadCartesianChart
>
We have a existing project that uses some older telerik libraries.
This application uses the RadRibbonView inside of an ElementHost control. It works great with the older telerik libraries.
I upgraded to the latest 2015 Q3 binaries and I am having problems.
The ribbon no longer displays in the element host.
I did some sanity checks by putting other telerik components into the element host, and they display fine.
Attached is a simple project that reproduces the issue.
Basically it creates a usercontrol.
Adds a simple ribbonview
Adds this ribbon view to a win forms control via element host.
Link to the project:
https://goo.gl/vJv5BG