Telerik Forums
UI for WPF Forum
5 answers
702 views

Hi:

I'm using the Telerik CUSTOM_MVVM_WPF example to build out a series of menus using

MVVM and RadMenuItems.

 

I'm having difficulty building out the MVVM  so that I can pass parameters to the

commands associated with the individual menu items.

How d I extend the implementation to achieve this?

 

Thanks,

JohnB

Nasko
Telerik team
 answered on 13 Mar 2017
4 answers
1.1K+ views
Client would like the keyboard cursor inside of the Combo Box when the Window loads. Calling "ComboBox.Focus()" does not place the keyboard cursor into the editable part of the ComboBox. Am I missing something simple? 
David
Top achievements
Rank 1
 answered on 13 Mar 2017
5 answers
222 views
Hi,
If Empty RadDateTimePicker not showed Validation Error in WPF, In Silverlight not problem, Please see screenshot. 
band
Top achievements
Rank 1
 answered on 10 Mar 2017
4 answers
226 views

I just moved one of my projects from VS 2015 where it was ok to VS 2017 and getting an error now when setting the width of a column. Before it was assigned a wildcard "*" now getting an error: "The TypeConverter for gridviewlength doesn't support converting from a string"

See attached screenshot

Stefan
Telerik team
 answered on 10 Mar 2017
1 answer
117 views

I'm having a problem with the ScheduleView.
My GroupHeaders style breaks when i try to add new resources. I think the easiest way to explain the problem is with the attached pictures. But my "outer" group header affects the "inner" group headers height (set to the same as the outer).
This also happens if I try to "reinitialize" the view with the exact same data as I had the first time.

I'm using a GroupHeaderContentTemplateSelector with a custom style.

The following is my view.

<Window x:Class="RadScheduleViewBug.MainWindow"
        xmlns:ignore="http://www.galasoft.ch/ignore"
        mc:Ignorable="d ignore"
        xmlns:local="clr-namespace:RadScheduleViewBug"
        xmlns:scheduleView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.ScheduleView"
        Height="500"
        Width="500"
        Title="MVVM Light Application"
        DataContext="{Binding Main, Source={StaticResource Locator}}">
 
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
 
            <DataTemplate x:Key="HorizontalTemplate">
                <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}"/>
            </DataTemplate>
 
            <DataTemplate x:Key="VerticalTemplate">
                <telerik:LayoutTransformControl>
                    <telerik:LayoutTransformControl.LayoutTransform>
                        <RotateTransform Angle="-90" />
                    </telerik:LayoutTransformControl.LayoutTransform>
                    <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}" VerticalAlignment="Top" ToolTipService.ToolTip="{Binding Name}" />
                </telerik:LayoutTransformControl>
            </DataTemplate>
 
            <DataTemplate x:Key="HorizontalResourceTemplate">
                <Border Margin="3" Width="100" MaxHeight="20">
                    <Border.Background>
                        <SolidColorBrush Color="White"></SolidColorBrush>
                    </Border.Background>
                    <StackPanel>
                        <TextBlock Margin="5" FontSize="12" Text="{Binding Name.DisplayName}" />
                    </StackPanel>
                </Border>
            </DataTemplate>
 
            <DataTemplate x:Key="VerticalResourceTemplate">
                <telerik:LayoutTransformControl Height="93">
                    <telerik:LayoutTransformControl.LayoutTransform>
                        <RotateTransform Angle="-90" />
                    </telerik:LayoutTransformControl.LayoutTransform>
                    <Border Margin="1,0,3,1">
                        <StackPanel>
                            <TextBlock Width="80" TextTrimming="CharacterEllipsis" Margin="5" FontSize="12" Text="{Binding Name.DisplayName}" ToolTipService.ToolTip="{Binding Name.DisplayName}">
                                <TextBlock.Foreground>
                                    <SolidColorBrush  Color="Red"/>
                                </TextBlock.Foreground>
                            </TextBlock>
                        </StackPanel>
                    </Border>
                </telerik:LayoutTransformControl>
            </DataTemplate>
 
            <local:CustomTimeRulerItemStyleSelector x:Key="CustomTimeRulerItemStyleSelector">
                <local:CustomTimeRulerItemStyleSelector.MajorTickLineStyle>
                    <Style TargetType="scheduleView:TimeRulerLine" BasedOn="{StaticResource TimeRulerLineStyle}">
                        <Setter Property="BorderBrush" Value="WhiteSmoke" />
                        <Setter Property="Background" Value="White" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="scheduleView:TimeRulerLine">
                                    <Border x:Name="LineVisual" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="1 0 0 0"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </local:CustomTimeRulerItemStyleSelector.MajorTickLineStyle>
 
                <local:CustomTimeRulerItemStyleSelector.MinorTickLineStyle>
                    <Style TargetType="scheduleView:TimeRulerLine" BasedOn="{StaticResource TimeRulerLineStyle}">
                        <Setter Property="BorderBrush" Value="WhiteSmoke" />
                        <Setter Property="Background" Value="White" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="scheduleView:TimeRulerLine">
                                    <Border x:Name="LineVisual" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="1 0 0 0"/>
 
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </local:CustomTimeRulerItemStyleSelector.MinorTickLineStyle>
            </local:CustomTimeRulerItemStyleSelector>
 
            <local:CustomGroupHeaderStyleSelector x:Key="CustomGroupHeaderStyleSelector">
                <local:CustomGroupHeaderStyleSelector.CalendarStyle>
                    <Style TargetType="telerik:GroupHeader">
                        <Setter Property="Margin" Value="0, 0, 0, 15" />
                        <Setter Property="BorderThickness" Value="0, 0, 0, 0" />
                    </Style>
                </local:CustomGroupHeaderStyleSelector.CalendarStyle>
                <local:CustomGroupHeaderStyleSelector.ChildStyle>
                    <Style TargetType="telerik:GroupHeader">
                        <Setter Property="BorderThickness" Value="0, 0, 0, 0" />
                        <Setter Property="BorderBrush" Value="WhiteSmoke" />
                    </Style>
                </local:CustomGroupHeaderStyleSelector.ChildStyle>
            </local:CustomGroupHeaderStyleSelector>
 
            <local:CustomGroupHeaderContentTemplateSelector x:Key="CustomGroupHeaderContentTemplateSelector" HorizontalTemplate="{StaticResource HorizontalTemplate}" VerticalResourceTemplate="{StaticResource VerticalResourceTemplate}" HorizontalResourceTemplate="{StaticResource HorizontalResourceTemplate}" VerticalTemplate="{StaticResource VerticalTemplate}"/>
 
        </ResourceDictionary>
    </Window.Resources>
 
    <Grid x:Name="LayoutRoot">
 
        <StackPanel>
            <telerik:RadButton Content="Add appointment" Command="{Binding AddNewAppointment}"/>
            <telerik:RadButton Content="Remove appointment" Command="{Binding RemoveAppointment}"/>
            <telerik:RadButton Content="Add measure point" Command="{Binding AddMeasurePoint}"/>
            <telerik:RadButton Content="Remove measure point" Command="{Binding RemoveMeasurePoint}"/>
            <telerik:RadButton Content="Re-initialize" Command="{Binding Redo}"/>
 
            <telerik:RadScheduleView ScrollViewer.CanContentScroll="True" Grid.Row="1" x:Name="Schedule"
                                    AppointmentsSource="{Binding Appointments, Mode=OneWay}"
                                    ResourceTypesSource="{Binding ResourceTypes, Mode=OneWay}"
                                    CategoriesSource="{Binding Categories, Mode=OneWay}"
                                    SelectedAppointment="{Binding SelectedAppointment, Mode=OneWay}"
                                    CurrentDate="{Binding PeriodStart, Mode=OneWay}"
                                    SelectedSlot="{Binding SelectedSlot, Mode=OneWay}"
                                    GroupHeaderContentTemplateSelector="{StaticResource CustomGroupHeaderContentTemplateSelector}"
                                    TimeRulerItemStyleSelector="{StaticResource CustomTimeRulerItemStyleSelector}"
                                    ShowCurrentTimeIndicator="True"
                                    NavigationHeaderVisibility="Collapsed"
                                    SpecialSlotStyleSelector="{StaticResource SpecialSlotStyleSelector}"
                                    SnapAppointments="True">
 
                <telerik:RadScheduleView.DragDropBehavior>
                    <local:CustomDragDropBehaviour/>
                </telerik:RadScheduleView.DragDropBehavior>
 
                <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu x:Name="radContextMenu" ItemsSource="{Binding ContextMenu}" />
                </telerik:RadContextMenu.ContextMenu>
 
                <telerik:RadScheduleView.ActiveViewDefinition>
                    <telerik:TimelineViewDefinition VisibleDays="{Binding Path=DataContext.VisibleDays, ElementName=Schedule, FallbackValue=3}"
                                                MaxTimeRulerExtent="Infinity"
                                                StretchAppointments="False"
                                                TimerulerMajorTickStringFormat="{}{0:H tt}"
                                                TimerulerGroupStringFormat="{}{0:dd-MM}"/>
                </telerik:RadScheduleView.ActiveViewDefinition>
 
                <telerik:RadScheduleView.GroupDescriptionsSource>
                    <telerik:GroupDescriptionCollection>
                        <scheduleView:DateGroupDescription />
                        <local:RSResourceGroupDescription ResourceType="Root" />
                        <local:RSResourceGroupDescription ResourceType="Child" />
                    </telerik:GroupDescriptionCollection>
                </telerik:RadScheduleView.GroupDescriptionsSource>
            </telerik:RadScheduleView>
 
        </StackPanel>
 
    </Grid>
</Window>

 

and the following is my ViewModel

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using RadScheduleViewBug.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Windows.Controls.ScheduleView;
using Telerik.Windows.Controls;
using System.Windows.Media;
using System.Collections.ObjectModel;
 
namespace RadScheduleViewBug.ViewModel
{
    public class MainViewModel : GalaSoft.MvvmLight.ViewModelBase
    {
        int _newAppId = 0;
        int _newMeasurePointId = 5;
        public RelayCommand AddMeasurePoint { get; set; }        
        public RelayCommand RemoveMeasurePoint { get; set; }
        public RelayCommand AddNewAppointment { get; set; }
        public RelayCommand RemoveAppointment { get; set; }
        public RelayCommand Redo { get; set; }
        public ObservableCollection<RSIntervalAppointment> Appointments { get; set; }
        public ObservableCollection<ResourceType> ResourceTypes { get; set; }
        public RSIntervalAppointment SelectedAppointment { get; set; }
        public Telerik.Windows.Controls.ScheduleView.Slot SelectedSlot { get; set; }
        public DateTime PeriodStart { get; set; }
        public DateTime IntervalEnd { get; set; }
        public int VisibleDays { get; set; } = 4;
 
        ResourceType rootResourceType;
        ResourceType childResourceType;
 
        Category scheduleCategory = new Category("Schedule", new SolidColorBrush(Colors.Red));
        Category shiftCategory = new Category("Shift", new SolidColorBrush(Colors.Green));
        Category breakCategory = new Category("Break", new SolidColorBrush(Colors.Blue));
 
        public MainViewModel()
        {
            InitializeAction();
 
            AddNewAppointment = new RelayCommand(AddNewAppointmentAction);
            RemoveMeasurePoint = new RelayCommand(RemoveMeasurePointAction);
            AddMeasurePoint = new RelayCommand(AddMeasurePointAction);
            RemoveAppointment = new RelayCommand(RemoveAppointmentAction);
 
            Redo = new RelayCommand(InitializeAction);
        }
 
        public void AddNewAppointmentAction()
        {
            _newAppId++;
 
            //New Appointment
            var app = new RSIntervalAppointment(new ProxyItem() { IntervalStart = DateTime.Now.AddHours(_newAppId).AddMinutes(1), IntervalEnd = DateTime.Now.AddHours(_newAppId + 1).AddMinutes(-1), Name = _newAppId.ToString() });
 
            app.Resources.Add(childResourceType.Resources.Last());
            app.Resources.Add(rootResourceType.Resources.Last());
            app.Category = shiftCategory;
 
            Appointments.Add(app);
        }
 
        private void RemoveAppointmentAction()
        {
            if(Appointments.Count > 0)
                Appointments.Remove(Appointments.Last());
        }
 
        private void AddMeasurePointAction()
        {
            _newMeasurePointId++;
 
            var resource = new RSReportItemResource(new ReportItem() { Name = _newMeasurePointId.ToString() }, "Measure p " + _newMeasurePointId.ToString());
            rootResourceType.Resources.Add(resource);
 
            //Refresh view
            ResourceTypes.Remove(childResourceType);
            ResourceTypes.Add(childResourceType);
        }
 
        private void RemoveMeasurePointAction()
        {
            if(rootResourceType.Resources.Count > 1)
            {
                rootResourceType.Resources.Remove(rootResourceType.Resources.Last());
 
                //Refresh view
                ResourceTypes.Remove(rootResourceType);
                ResourceTypes.Add(rootResourceType);
            }
        }
 
        public void InitializeAction()
        {
            ResourceTypes = new ObservableCollection<ResourceType>();
 
            rootResourceType = new ResourceType("Root");
            childResourceType = new ResourceType("Child");
 
            ResourceTypes.Add(rootResourceType);
            ResourceTypes.Add(childResourceType);
 
            var measurePoint1 = new RSReportItemResource(new ReportItem() { Name = "1" }, "Measure point 1");
            rootResourceType.Resources.Add(measurePoint1);
 
            var measurePoint2 = new RSReportItemResource(new ReportItem() { Name = "1" }, "Measure point 2");
            rootResourceType.Resources.Add(measurePoint2);
 
            var schedule = new RSEntityTypeResource(new ProxyItem(), "Schedule");
            childResourceType.Resources.Add(schedule);
 
            var breaks = new RSEntityTypeResource(new ProxyItem(), "Breaks");
            childResourceType.Resources.Add(breaks);
 
            var shift = new RSEntityTypeResource(new ProxyItem(), "Shift");
            childResourceType.Resources.Add(shift);
 
            PeriodStart = DateTime.Now.AddDays(-1);
 
            Appointments = new ObservableCollection<RSIntervalAppointment>();
 
            for (var i = 0; i < 10; i++)
            {
                var app = new RSIntervalAppointment(new ProxyItem() { IntervalStart = DateTime.Now.AddHours(-i), IntervalEnd = DateTime.Now.AddHours(-i + 1), Name = i.ToString() });
                app.Resources.Add(childResourceType.Resources[0]);
                app.Resources.Add(rootResourceType.Resources[0]);
                app.Category = scheduleCategory;
                Appointments.Add(app);
            }
 
            for (var i = 0; i < 10; i++)
            {
                var app = new RSIntervalAppointment(new ProxyItem() { IntervalStart = DateTime.Now.AddHours(-i), IntervalEnd = DateTime.Now.AddHours(-i + 1), Name = i.ToString() });
                app.Resources.Add(childResourceType.Resources[2]);
                app.Resources.Add(rootResourceType.Resources[0]);
                app.Category = shiftCategory;
                Appointments.Add(app);
            }
 
            RaisePropertyChanged(() => ResourceTypes);
            RaisePropertyChanged(() => Appointments);
        }
    }
}

This all the code needed to recreate the problem in a MvvmLight project. 

You can clearly see the error in the attached files. 

I have also made a project with a recreation of the problem that I can send you if that would help you in assisting me. 

Dilyan Traykov
Telerik team
 answered on 10 Mar 2017
1 answer
104 views

After deserialization Cyrillic is displayed as unknown characters, could you suggest how to fix it?

public void diagram_ShapeDeserialized(object sender, Telerik.Windows.Controls.Diagrams.ShapeSerializationRoutedEventArgs e)
        {
            try
            {
                if (e.Shape is FunctionShape)
                {
                    FunctionShape shape = e.Shape as FunctionShape;

                    if (e.SerializationInfo["DisplayName"] != null)
                        shape.DisplayName = e.SerializationInfo["DisplayName"].ToString();

                  }

             }
        }

 

For example, this function

 

<FunctionItem>
      <DisplayName>ИЛИ</DisplayName>
      <FunctionName>OR</FunctionName>
      <InputCount>2</InputCount>
      <OutputCount>1</OutputCount>
      <Code>//OR Gate
IN(data0)
OR(data1)
OUT(out0)
</Code>
      <FunctionType>Logic</FunctionType>
      <LeftEdge>0</LeftEdge>
      <RightEdge>1</RightEdge>
      <Data>M 281,290L 319,290C 319.552,290 320,289.552 320,289L 320,251C 320,250.448 319.552,250 319,250L 281,250C 280.448,250 280,250.448 280,251L 280,289C 280,289.552 280.448,290 281,290 Z M 280,260L 270,260M 280,280L 270,280M 320,270L 330,270M 302.569,264.156L 307.476,262.656M 302.493,277.666L 312.288,277.666M 307.455,277.385L 307.455,262.228M 287.814,277.664L 296.856,277.664M 287.731,275.747L 296.819,271.106M 287.814,266.164L 296.788,271.278</Data>
      <Width>60</Width>
      <Height>40</Height>
      <Stroke>#FF000000</Stroke>
      <Fill>#FFFF7D00</Fill>
      <StrokeThickness>1</StrokeThickness>
      <Connectors>
        <FunctionItemConnector>
<PinNomber>1</PinNomber>
          <X>0</X>
          <Y>0.25</Y>
          <Direction>Input</Direction>
        </FunctionItemConnector>
        <FunctionItemConnector>
<PinNomber>2</PinNomber>
          <X>0</X>
          <Y>0.75</Y>
          <Direction>Input</Direction>
        </FunctionItemConnector>
        <FunctionItemConnector>
<PinNomber>1</PinNomber>
          <X>1</X>
          <Y>0.5</Y>
          <Direction>Output</Direction>
        </FunctionItemConnector>
      </Connectors>
      <Index>3</Index>
    </FunctionItem>

Martin Ivanov
Telerik team
 answered on 09 Mar 2017
5 answers
1.0K+ views
I have a strange problem and am looking into it for two days now.

I want to achieve that the radgridview's data is refreshed with the latest data from the database with no noticable delay in UI. So I definately don't want to do a rebind.
The grid's ItemsSource binds to an OberservableCollection(Of poco).
The thing I do is send this ObservableCollection to the dbContext (Telerik DataAccess EntitiesModel class):

dbContext.Refresh(Telerik.OpenAccess.RefreshMode.OverwriteChangesFromStore, toPoco)
After this refresh I fire the PropertyChanged event of the property holding the ObservableCollection.

Here's what happens:
Gridview's UI isn't updated. When I scroll the grid so a gridrow that has been changed is out of view and scroll the changed row back into view, the gridrow does show the right (changed!) data from SQL server.

It looks like the grid isn't getting a signal that the collection has been changed so it doen't update it's UI.

What could i do to refresh the gridview the right way?

Alexander
Dilyan Traykov
Telerik team
 answered on 09 Mar 2017
0 answers
100 views

Hi, 

I need to be able to bind the SelectedItems property of the RadGridView to a ObservableCollection property of my ViewModel. So I use the "MySelectedItemsBindingBehavior" class I found on your sample project called BindingSelectedItemsFromViewModel_WPF (found on github).

 

I would like to know why in this class, there is a static Attached boolean property.

In fact, if I load the same UserControl twice, only the first one is able to bind correctly its ObservableCollection to the SelectedItems of the RadGridView.

Is there a reason why you added this static boolean?

 

Thanks in advance

Sylvain
Top achievements
Rank 1
 asked on 09 Mar 2017
1 answer
60 views

Is it possible to set a Reccurrence Rule so that an appointment could happen every hour for days, but only between like 10am-4pm?   I can easily create an hourly pattern that lasts for days, but don't know how to make it only happen between a certain range in a day.

 

Thanks!

Martin
Telerik team
 answered on 09 Mar 2017
1 answer
131 views

Hi,

I have a column which DataType is TimeSpan, TimeSpans are displayed in military time format("hhmm"), however when user types 2000, filter interprets it as 2000 days 0 hours 0 minutes 0 seconds(2000.00:00:00). Filter checkBoxes also display values in the format specified. How can I make filter parse 2000 as 0.20:00:00?

Is there an easy way to do this?

Dilyan Traykov
Telerik team
 answered on 09 Mar 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?