Telerik Forums
UI for WPF Forum
1 answer
64 views
Hi,

After implementing the custom filter row in the grid view, I noticed that the row indicator (column 0 when RowIndicatorVisibility = Visible) is not functioning correctly.  The background brush changes as you select rows, but the arrow (>) just stays on the first row.

This behaviour is the same in your demo application.

Thanks.
Maya
Telerik team
 answered on 23 Feb 2011
3 answers
116 views
I'm trying to tweak the style of the new Expression Dark skin and I'm following the tutorials about how to do this using expression blend. However the tutorial instructs that I should do the following:

Object -> Edit Additional Styles -> RowStyle -> Edit A Copy

However, when I attempt this the Edit A Copy option is greyed out and unselectable. Does any one have any idea why this is, or how to get around it?
Mark
Top achievements
Rank 1
 answered on 23 Feb 2011
1 answer
294 views
Hi,
I have a multple gridview with RadContextMenu.  It all have the same menu items.... If set the property Icon="{StaticResource imgSearchMenu}" for RadMenuItem.. the image is not showing...

Did I missed something here?

Thank you in advance,
TM

-- Code--

<UserControl.Resources>
<DataTemplate x:Key="Col1">
            <DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <TextBox Text="{Binding Path=col_name1}"  />
            </DockPanel>
        </DataTemplate>
<DataTemplate x:Key="imgSearchMenu">
   <Grid>
<Image Source="{lib:LocImage Key=Search,Dict=Resources,Assembly=MyApp.Client.Shell}" />
   </Grid>
</DataTemplate>

</UserControl.Resources>

<telerik:RadGridView 
    Name="gridMyList"
    AutoGenerateColumns="False" 
    ShowGroupPanel="False" 
    ItemsSource="{Binding myList}"
    SelectedItem="{Binding currentRecord}">
    <telerik:RadGridView.Columns>
<telerik:GridViewDataColumn
   Header="Col 1" 
   IsReadOnly="True"
   CellTemplate="{StaticResource Col1}" />
<telerik:GridViewDataColumn 
    </telerik:RadGridView.Columns>
    <telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu
   Name="menu1" 
   Opened="RadContextMenu_Opened" 
   ItemClick="RadContextMenu_ItemClick">
   <telerik:RadContextMenu.Items>
<telerik:RadMenuItem Header="Add" Icon="{StaticResource imgSearchMenu}" />
<telerik:RadMenuItem Header="|" IsSeparator="True" />
<telerik:RadMenuItem Header="Another item" />
   </telerik:RadContextMenu.Items>
</telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
</telerik:RadGridView>
Konstantina
Telerik team
 answered on 23 Feb 2011
3 answers
231 views
Hello,

I need to adjust appointment panel length every time ActiveViewDefinition is switched to prevent content scroll.

I try using MaxTimeRulerExtent property but can't find proper way to update it. Its value should be calculated as appointmnet panel length substract total headers length. The headers length is updated within MeasureOverride(). But ActiveViewDefinition changed event is rised prior to Measure/Arrange when I change active view.

What event should I listen or what another way suits better?

Thanks,
Anatoly
Valeri Hristov
Telerik team
 answered on 23 Feb 2011
3 answers
260 views
Hello,

First of all congrats on the new WPF Q3 SP1 release. The WPF controls looks really great.
For the ScheduleView I really like the SpecialSlots styling, this is exactly what we needed.

So here's my question,

I'm using a group filter on the resources that are in the selected appointment. That way only resources that have a correlation with the selected appointment are shown (along with their availabilities). Now, when I change the a resource for the selected appointment, the calendar is updated accordingly (showing the new resource and it's availability). Until now everything is as expected. However after the update the scroll bar is back on top and not where it was before. So how would I set the scroll bar.

I see several options.
1. Make it possible to scroll to a certain time. (independent of zoom level)
2. Autoscroll to the selected appointment.

How would you guys go about this?

Thanks,
Nico


Pana
Telerik team
 answered on 23 Feb 2011
1 answer
139 views
Hi,

   I'm trying to add Context Menu to MapPolylines and somehow it is not displaying the context menu. My requirement is to Right Click on MapPolyline and select Hide Polyline from Context Menu. Please see the code below:

Registering this event when drawing Polyline

 

 

private void techpolyline_MouseRightButtonDown(object sender, MouseButtonEventArgs e)

 

 

{

 

 

 

MapPolyline rightClickPolyline;

 

 

 

 

ContextMenu mainMenu = new ContextMenu();

 

 

mainMenu.Background =

 

Brushes.LightBlue;

 

 

mainMenu.Height = 50;

 

mainMenu.Width = 120;

 

 

 

MenuItem baseItem = new MenuItem();

 

 

baseItem.Width = 120;

 

baseItem.Header =

 

"Select Action";

 

 

baseItem.Background =

 

Brushes.Blue;

 

 

baseItem.Foreground =

 

Brushes.White;

 

 

baseItem.FontWeight =

 

FontWeights.Bold;

 

 

mainMenu.Items.Add(baseItem);

 

 

 

 

 

MenuItem hidepolygonItem = new MenuItem();

 

 

hidepolygonItem.Width = 120;

 

hidepolygonItem.Header =

 

"Hide Polyline";

 

 

mainMenu.Items.Add(hidepolygonItem);

 

 

 

//hidepolygonItem.PreviewMouseLeftButtonDown +=new MouseButtonEventHandler(hidepolygonItem_PreviewMouseLeftButtonDown);

 

 

 

if (sender.GetType() == typeof(MapPolyline))

 

 

{

 

  rightClickPolyline = (

 

MapPolyline)sender;

 

 

  rightClickPolyline.ContextMenu = mainMenu;

 

}

 

}


I use the same logic to MapPinPoint items and Pushpin items and it works. Any help is appreciated.

Regards!!
Paddy
Andrey
Telerik team
 answered on 23 Feb 2011
0 answers
265 views
Once i have mouseover to the window it will change to full screen windows and the video will also change to fullscreen but i have a error is that when i mouseover again i have it back to normal windows but my video is not back to normal video size as the normal window and still remain the fullscreen video size.

XAML code
<Window x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid>
        <DockPanel Name="LayoutRoot" />
        <MediaElement Canvas.Left="20" Canvas.Top="40" Name="VideoControl" LoadedBehavior="Play" UnloadedBehavior="Stop" />
        <telerik:RadButton telerik:StyleManager.Theme="Transparent" Content="Close" Height="Auto" HorizontalAlignment="Left" Margin="26,199,0,0" Name="PlayButton" VerticalAlignment="Top" Width="Auto" Click="PlayButton_Click" Visibility="Visible" />
    </Grid>
</Window>

C# Code
namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            bool fullscreen = false;
            InitializeComponent();
            VideoControl.Volume = 100;
             
 
 
           VideoControl.MouseMove += delegate
            {
              //fullscreen mode
            if (!fullscreen)
             {
 
                    //LayoutRoot.Children.Remove(VideoControl);
                    //this.Content = VideoControl;
                    this.WindowStyle = WindowStyle.None;
                    this.WindowState = WindowState.Maximized;
                    VideoControl.Width = 1850;
                    VideoControl.Height = 1850;
                     
                     
                }
                else
                {
                    //non fullscreen mode
                    //this.Content = LayoutRoot;
                    //LayoutRoot.Children.Add(VideoControl);
                    this.WindowStyle = WindowStyle.SingleBorderWindow;
                    this.WindowState = WindowState.Normal;
                    VideoControl.Width = 1000;
                    VideoControl.Height = 1000;
                     
 
                     
                     
                     
                     
                }
 
                fullscreen = !fullscreen;
 
 
            };
        }
 
             
 
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            VideoControl.Source = new Uri("C:\\Users\\Public\\Videos\\Sample Videos\\Wildlife.wmv");
        }
 
        private void PlayButton_Click(object sender, RoutedEventArgs e)
        {
            //VideoControl.Play();
            Close();
        }
 
    }
}
Edwin
Top achievements
Rank 1
 asked on 23 Feb 2011
3 answers
187 views
I am running into a performance issue where I have a HierarchyChildTemplate that shows a RadGridView with 10000+ data items. The initial databinding to the toplevel works very fast but trying to expand the hierarchy takes an incredible amount of time. I've tried using different combination the following to improve performance but they don't have any effect on the internal RadGridView.

DataLoadMode="Asynchronous"
ScrollMode="Deferred"
EnableRowVirtualization="True"

Is there a way to improve the performance or is this a bug?

Thanks,
Shawn

Here is my XAML:
<Telerik:RadGridView x:Name="ResultGrid" Grid.Row="1"
                                 VerticalAlignment="Stretch"
                                 CanUserReorderColumns="False"
                                 AutoGenerateColumns="False"
                                 Height="Auto"
                                 ScrollMode="Deferred"
                                 DataLoadMode="Asynchronous"
                                 EnableRowVirtualization="True"                                 
                                 ShowGroupPanel="False"
                                 Margin="2"
                                 IsReadOnly="True"
                                 BorderThickness="2">
    <Telerik:RadGridView.ChildTableDefinitions>
        <Telerik:GridViewTableDefinition >
        </Telerik:GridViewTableDefinition>
    </Telerik:RadGridView.ChildTableDefinitions>
    <Telerik:RadGridView.Columns>
        <Telerik:GridViewDataColumn Header="Mission" DataMemberBinding="{Binding MissionName, Mode=OneWay}" IsReadOnly="True"/>
        <Telerik:GridViewDataColumn Header="Antenna" DataMemberBinding="{Binding AntennaName, Mode=OneWay}" IsReadOnly="True"/>
    </Telerik:RadGridView.Columns>
    <Telerik:RadGridView.HierarchyChildTemplate>
        <DataTemplate>
            <Telerik:RadGridView x:Name="ResultGridChild"
                                 CanUserFreezeColumns="False"
                                 AutoGenerateColumns="True"
                                 ItemsSource="{Binding Locations}"
                                 ShowGroupPanel="False"
                                 IsReadOnly="True" IsFilteringAllowed="False" CanUserDeleteRows="False" CanUserInsertRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserSelect="False" CanUserSortColumns="False">
                <Telerik:RadGridView.Columns>
                    <Telerik:GridViewDataColumn DataMemberBinding="{Binding Latitude}" Header="Latitude" />
                    <Telerik:GridViewDataColumn DataMemberBinding="{Binding Longitude}" Header="Longitude" />
                    <Telerik:GridViewDataColumn DataMemberBinding="{Binding Longitude}" Header="Altitude" />
                    <Telerik:GridViewDataColumn DataMemberBinding="{Binding Value}" Header="Value" />
                </Telerik:RadGridView.Columns>
            </Telerik:RadGridView>
        </DataTemplate>
    </Telerik:RadGridView.HierarchyChildTemplate>
</Telerik:RadGridView>


John
Top achievements
Rank 1
 answered on 22 Feb 2011
3 answers
271 views
Hello,

I'm just implementing the External filter as explained in the help : here
I'm building a grid based on a model.

When the FilterValue is updated when the text changes, I receive a "Input string was not in a correct format."

Here is some detail :

Stacktrace :
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)

   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Telerik.Windows.Data.Expressions.FilterDescriptorExpressionBuilder.CreateValueExpression(Type targetType, Object value, CultureInfo culture)

   at Telerik.Windows.Data.Expressions.FilterDescriptorExpressionBuilder.CreateBodyExpression()
   at Telerik.Windows.Data.FilterDescriptor.CreateFilterExpression(ParameterExpression parameterExpression)
   at Telerik.Windows.Data.FilterDescriptorBase.CreateFilterExpression(Expression instance)
   at Telerik.Windows.Data.Expressions.FilterDescriptorCollectionExpressionBuilder.CreateBodyExpression()
   at Telerik.Windows.Data.CompositeFilterDescriptor.CreateFilterExpression(ParameterExpression parameterExpression)
   at Telerik.Windows.Data.FilterDescriptorBase.CreateFilterExpression(Expression instance)

at CustomFilterDescriptor.CreateFilterExpression(ParameterExpression parameterExpression) in \CustomFilterDescriptor.cs:line 45

   at Telerik.Windows.Data.FilterDescriptorBase.CreateFilterExpression(Expression instance)
   at Telerik.Windows.Data.Expressions.FilterDescriptorCollectionExpressionBuilder.CreateBodyExpression()
   at Telerik.Windows.Data.Expressions.FilterExpressionBuilder.CreateFilterExpression()
   at Telerik.Windows.Data.QueryableExtensions.Where(IQueryable source, CompositeFilterDescriptorCollection filterDescriptors)

   at Telerik.Windows.Data.QueryableCollectionView.CreateView()
   at Telerik.Windows.Data.QueryableCollectionView.get_QueryableView()
   at Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
   at Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList()
   at Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
   at Telerik.Windows.Data.QueryableCollectionView.get_InternalCount()
   at Telerik.Windows.Data.QueryableCollectionView.get_IsEmpty()
   at Telerik.Windows.Data.QueryableCollectionView.InitializeCurrencyOnRefresh()
   at Telerik.Windows.Data.QueryableCollectionView.RefreshOverride()
   at Telerik.Windows.Data.QueryableCollectionView.RefreshInternal()
   at Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer()
   at Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh()
   at Telerik.Windows.Data.QueryableCollectionView.OnFilterDescriptorsItemChanged(Object sender, ItemChangedEventArgs`1 e)

   at Telerik.Windows.Data.ObservableItemCollection`1.RaiseGenericItemChanged(ItemChangedEventArgs`1 e)
   at Telerik.Windows.Data.ObservableItemCollection`1.OnItemChanged(ItemChangedEventArgs`1 e)
   at Telerik.Windows.Data.ObservableItemCollection`1.OnItemPropertyChanged(Object sender, PropertyChangedEventArgs e)
   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   at Telerik.Windows.Data.DescriptorBase.OnPropertyChanged(PropertyChangedEventArgs args)
   at Telerik.Windows.Data.DescriptorBase.OnPropertyChanged(String propertyName)
   at CustomFilterDescriptor.set_FilterValue(String value) in CustomFilterDescriptor.cs:line 32

   at FilterValueTextChanged(Object sender, TextChangedEventArgs e) in MyClass.xaml.cs:line 43

   at System.Windows.Controls.TextChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Primitives.TextBoxBase.OnTextChanged(TextChangedEventArgs e)
   at System.Windows.Controls.Primitives.TextBoxBase.OnTextContainerChanged(Object sender, TextContainerChangedEventArgs e)

   at System.Windows.Controls.TextBox.OnTextContainerChanged(Object sender, TextContainerChangedEventArgs e)
   at System.Windows.Documents.TextContainerChangedEventHandler.Invoke(Object sender, TextContainerChangedEventArgs e)
   at System.Windows.Documents.TextContainer.EndChange(Boolean skipEvents)
   at System.Windows.Documents.TextContainer.System.Windows.Documents.ITextContainer.EndChange(Boolean skipEvents)
   at System.Windows.Documents.TextRangeBase.EndChange(ITextRange thisRange, Boolean disableScroll, Boolean skipEvents)
   at System.Windows.Documents.TextRange.System.Windows.Documents.ITextRange.EndChange(Boolean disableScroll, Boolean skipEvents)

   at System.Windows.Documents.TextRange.ChangeBlock.System.IDisposable.Dispose()
   at System.Windows.Documents.TextEditorTyping.DoTextInput(TextEditor This, String textData, Boolean isInsertKeyToggled, Boolean acceptControlCharacters)

   at System.Windows.Documents.TextEditorTyping.TextInputItem.Do()
   at System.Windows.Documents.TextEditorTyping.ScheduleInput(TextEditor This, InputItem item)
   at System.Windows.Documents.TextEditorTyping.OnSpace(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)

   at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)

   at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)

   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
   at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)
   at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
   at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)

   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)

   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window) 
  

Any idea ?

Thanks by advance.

Xavier

Maya
Telerik team
 answered on 22 Feb 2011
3 answers
216 views
HI! All,

    

I have a work around solution to change the background  colour of the selected date. Please if anyone can improve the code or have a better solution can please update me.

 

XAML Code

<Window x:Class="TelerikDateSelectCal.Window1"
    xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"        
    xmlns:local="clr-namespace:TelerikDateSelectCal"
    Title="Window1" Height="300" Width="552"
    xml:lang="en-GB">
    <Window.Resources>
          
        <local:CustomTemplateSelector x:Key="WorksDiaryDayTemplateSelector">
              
            <local:CustomTemplateSelector.SelectedRed>
                <DataTemplate>
                    <Border Background="Red" Width="20">
                        <TextBox Background="Transparent" Text="{Binding Text}"
                        BorderThickness="0"/>
                    </Border>
                </DataTemplate>
            </local:CustomTemplateSelector.SelectedRed>
  
            <local:CustomTemplateSelector.SelectedGreen>
                <DataTemplate>
                    <Border Background="Green" Width="20">
                        <TextBox Background="Transparent" Text="{Binding Text}"
                        BorderThickness="0"/>
                    </Border>
                </DataTemplate>
            </local:CustomTemplateSelector.SelectedGreen>
  
            <local:CustomTemplateSelector.SelectedBlue>
                <DataTemplate>
                    <Border Background="Blue" Width="20">
                        <TextBox Background="Transparent" Text="{Binding Text}"
                        BorderThickness="0"/>
                    </Border>
                </DataTemplate>
            </local:CustomTemplateSelector.SelectedBlue>
  
            <local:CustomTemplateSelector.SelectedYellow>
                <DataTemplate>
                    <Border Background="Yellow" Width="20">
                        <TextBox Background="Transparent" Text="{Binding Text}"
                        BorderThickness="0"/>
                    </Border>
                </DataTemplate>
            </local:CustomTemplateSelector.SelectedYellow>
  
            <local:CustomTemplateSelector.SelectedBlank>
                <DataTemplate x:Name="Test">
                        <TextBox Background="Transparent" Text="{Binding Text}"
                        BorderThickness="0" Width="20"/>
                </DataTemplate>
                </local:CustomTemplateSelector.SelectedBlank>
        </local:CustomTemplateSelector>
  
  
  
    </Window.Resources>
      
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="20*"/>
        </Grid.ColumnDefinitions>
          
        <Grid Grid.Column="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="20*"/>
            </Grid.ColumnDefinitions>
  
            <StackPanel Grid.Column="0">
                <Button Name="btnRed" Width="20" Height="20" Margin="3" Background="Red" Click="SetComboOpen"/>
                <Button Name="btnGreen" Width="20" Height="20" Margin="3" Background="Green" Click="SetComboOpen"/>
                <Button Name="btnBlue" Width="20" Height="20" Margin="3" Background="Blue" Click="SetComboOpen"/>
                <Button Name="btnYellow" Width="20" Height="20" Margin="3" Background="Yellow" Click="SetComboOpen"/>
                  
                <TextBox Margin="4" Name="txt1" Height="50" BorderBrush="BlueViolet" TextWrapping="Wrap"
                         Width="150"></TextBox>
                  
            </StackPanel>
              
            <StackPanel Grid.Column="1">
                <ComboBox Name="cmbRed" Width="175" Margin="2" DropDownClosed="SetCacBackColor" >
                    <ComboBoxItem>Red</ComboBoxItem>
                </ComboBox>
                <ComboBox Name="cmbGreen" Width="175" Margin="2" DropDownClosed="SetCacBackColor">
                    <ComboBoxItem>Green</ComboBoxItem>
                </ComboBox>
                <ComboBox Name="cmbBlue" Width="175" Margin="2" DropDownClosed="SetCacBackColor">
                    <ComboBoxItem>Blue</ComboBoxItem>
                </ComboBox>
                <ComboBox Name="cmbYellow" Width="175" Margin="2" DropDownClosed="SetCacBackColor">
                    <ComboBoxItem>Yellow</ComboBoxItem>
                </ComboBox>
            </StackPanel>
        </Grid>
  
        <telerik:RadCalendar x:Name="calendar" Grid.Column="1"
                Margin="2" SelectionMode="Single"
                IsTodayHighlighted="True" ViewsHeaderVisibility="Collapsed" Culture="en-GB"
                Rows="3" Columns="4" 
                SelectionChanged="calendar_SelectionChanged"
                DayTemplateSelector="{StaticResource WorksDiaryDayTemplateSelector}"/>
    </Grid>
</Window>

C# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
  
using Telerik;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Calendar;
  
using System.ComponentModel;
using System.Collections.ObjectModel;
  
using System.Data;
#if !SILVERLIGHT
using SelectionChangedEventArgs = System.Windows.Controls.SelectionChangedEventArgs;
using DataTemplateSelector = System.Windows.Controls.DataTemplateSelector;
#endif
  
namespace TelerikDateSelectCal
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        List<DateTime> lstRedDate;
        List<DateTime> lstGreenDate;
        List<DateTime> lstBlueDate;
        List<DateTime> lstYellowDate;
  
        public Window1()
        {
            InitializeComponent();
  
            lstRedDate = new List<DateTime>();
            lstGreenDate = new List<DateTime>();
            lstBlueDate = new List<DateTime>();
            lstYellowDate = new List<DateTime>();
  
            setAllComboENFalse();
            this.cmbRed.IsEnabled = true;
  
            setSelectedDateGlbColor("Red");
        }
  
        private void SetCacBackColor(object sender, EventArgs e)
        {
  
        }
  
        private void SetComboOpen(object sender, RoutedEventArgs e)
        {
            setAllComboENFalse();
            string selecteColor = "";
  
            if (sender == btnRed)
            {
                this.cmbRed.IsEnabled = true;
                selecteColor = "Red";
            }
            else if (sender == btnGreen)
            {
                this.cmbGreen.IsEnabled = true;
                selecteColor = "Green";
            }
            else if (sender == btnBlue)
            {
                this.cmbBlue.IsEnabled = true;
                selecteColor = "Blue";
            }
            else if (sender == btnYellow)
            {
                this.cmbYellow.IsEnabled = true;
                selecteColor = "Yellow";
            }
  
            setSelectedDateGlbColor(selecteColor);
        }
  
        protected void setSelectedDateGlbColor(string selectedColorName)
        {
            if (Application.Current.Properties.Contains("SelectedColor"))
                Application.Current.Properties.Remove("SelectedColor");
  
            Application.Current.Properties.Add("SelectedColor", selectedColorName);
        }
  
        protected void setAllComboENFalse()
        {
            this.cmbRed.IsEnabled = false;
            this.cmbGreen.IsEnabled = false;
            this.cmbBlue.IsEnabled = false;
            this.cmbYellow.IsEnabled = false;
        }
  
        private void calendar_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Application.Current.Properties.Contains("SelectedColor"))
            {
                string selectedColor = Application.Current.Properties["SelectedColor"].ToString();
  
                switch (selectedColor)
                {
                    case "Red":
                        lstRedDate.Add((DateTime)calendar.SelectedDate.Value);
  
                        if (Application.Current.Properties.Contains("RedColor"))
                            Application.Current.Properties.Remove("RedColor");
  
                        Application.Current.Properties.Add("RedColor", lstRedDate);
  
                        break;
  
                    case "Green":
                        lstGreenDate.Add((DateTime)calendar.SelectedDate.Value);
  
                        if (Application.Current.Properties.Contains("GreenColor"))
                            Application.Current.Properties.Remove("GreenColor");
  
                        Application.Current.Properties.Add("GreenColor", lstGreenDate);
  
                        break;
  
                    case "Blue":
                        lstBlueDate.Add((DateTime)calendar.SelectedDate.Value);
  
                        if (Application.Current.Properties.Contains("BlueColor"))
                            Application.Current.Properties.Remove("BlueColor");
  
                        Application.Current.Properties.Add("BlueColor", lstBlueDate);
  
                        break;
  
                    case "Yellow":
                        lstYellowDate.Add((DateTime)calendar.SelectedDate.Value);
  
                        if (Application.Current.Properties.Contains("YellowColor"))
                            Application.Current.Properties.Remove("YellowColor");
  
                        Application.Current.Properties.Add("YellowColor", lstYellowDate);
  
                        break;
  
                    default:
                        MessageBox.Show("Invalid Date Color....", "Message....", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        break;
                }
  
  
                DateTime tempDate;
                tempDate = new DateTime(calendar.DisplayDate.Year, calendar.DisplayDate.Month, 1);
                calendar.DisplayDate = tempDate.AddYears(8);
                calendar.DisplayDate = tempDate;
            }
            else
            {
                MessageBox.Show("Please Select a date Color ", "Message....", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
    }
  
    [Serializable()]
    public class CustomTemplateSelector : DataTemplateSelector
    {
        // ObservableCollection<Object> listTabsValue = new ObservableCollection<object>();
  
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            CalendarButtonContent content = item as CalendarButtonContent;
            string daySelColorFlg = "";
            List<DateTime> lstDtRed = (List<DateTime>)Application.Current.Properties["RedColor"];
            List<DateTime> lstDtGreen = (List<DateTime>)Application.Current.Properties["GreenColor"];
            List<DateTime> lstDtBlue = (List<DateTime>)Application.Current.Properties["BlueColor"];
            List<DateTime> lstDtYellow = (List<DateTime>)Application.Current.Properties["YellowColor"];
  
            if (Application.Current.Properties.Contains("SelectedColor"))
            {
                daySelColorFlg = Application.Current.Properties["SelectedColor"].ToString();
            }
            else
                return SelectedBlank ;
              
  
            if (content.ButtonType == CalendarButtonType.Date
                || content.ButtonType == CalendarButtonType.TodayDate)
            {
                switch (daySelColorFlg)
                {
                    case "Red":
                          
                        if (lstDtRed != null)
                        {
                            if (lstDtRed.Contains(content.Date))
                                return SelectedRed;
                            else if (lstDtGreen != null || lstDtBlue != null || lstDtYellow != null)
                            {
                                if(lstDtGreen != null)
                                    if (lstDtGreen.Contains(content.Date))
                                        return SelectedGreen;
  
                                if (lstDtBlue != null)
                                    if (lstDtBlue.Contains(content.Date))
                                        return SelectedBlue;
  
                                if (lstDtYellow != null)
                                    if (lstDtYellow.Contains(content.Date))
                                    return SelectedYellow;
                            }
                            else
                                return SelectedBlank;
                        }
                        else
                            return SelectedBlank;
  
                        break;
  
                    case "Green":
                          
                        if (lstDtGreen != null)
                        {
                            if (lstDtGreen.Contains(content.Date))
                                return SelectedGreen;
  
                            else if (lstDtRed != null || lstDtBlue != null || lstDtYellow != null)
                            {
                                if (lstDtRed != null)
                                    if (lstDtRed.Contains(content.Date))
                                        return SelectedRed;
  
                                if (lstDtBlue != null)
                                    if (lstDtBlue.Contains(content.Date))
                                        return SelectedBlue;
  
                                if (lstDtYellow != null)
                                    if (lstDtYellow.Contains(content.Date))
                                        return SelectedYellow;
                            }
                            else
                                return SelectedBlank;
                        }
                        else
                            return SelectedBlank;
  
                        break;
  
                    case "Blue":
  
                        if (lstDtBlue != null)
                        {
                            if (lstDtBlue.Contains(content.Date))
                                return SelectedBlue;
                            else if (lstDtRed != null || lstDtGreen != null || lstDtYellow != null)
                            {
                                if (lstDtRed != null)
                                    if (lstDtRed.Contains(content.Date))
                                        return SelectedRed;
                                if (lstDtGreen != null)
                                    if (lstDtGreen.Contains(content.Date))
                                        return SelectedGreen;
                                if (lstDtYellow != null)
                                    if (lstDtYellow.Contains(content.Date))
                                        return SelectedYellow;
                            }
                            else
                                return SelectedBlank;
                        }
                        else
                            return SelectedBlank;
  
                        break;
  
                    case "Yellow":
  
                        if (lstDtYellow != null)
                        {
                            if (lstDtYellow.Contains(content.Date))
                                return SelectedYellow;
                            else if (lstDtRed != null || lstDtGreen != null || lstDtBlue != null)
                            {
                                if (lstDtRed != null)
                                    if (lstDtRed.Contains(content.Date))
                                        return SelectedRed;
  
                                if (lstDtGreen != null)
                                    if (lstDtGreen.Contains(content.Date))
                                        return SelectedGreen;
  
                                if (lstDtBlue != null)
                                    if (lstDtBlue.Contains(content.Date))
                                        return SelectedBlue;
                            }
                            else
                                return SelectedBlank;
                        }
                        else
                            return SelectedBlank;
  
                        break;
  
                    default:
  
                        break;
                }
  
            }
            return SelectedBlank;
        }
  
        public DataTemplate SelectedRed
        {
            get;
            set;
        }
  
        public DataTemplate SelectedBlue
        {
            get;
            set;
        }
  
        public DataTemplate SelectedGreen
        {
            get;
            set;
        }
  
        public DataTemplate SelectedYellow
        {
            get;
            set;
        }
  
        public DataTemplate SelectedBlank
        {
            get;
            set;
        }
    }
}


Not best of the code, it's too lengthy and needs improvement so please le me know if you have improved it.

 

Thanks

Rahul


Rahul Singh
Top achievements
Rank 1
 answered on 22 Feb 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?