Telerik Forums
UI for WPF Forum
5 answers
371 views

I tried to work with Demo Example: Grupping - Advanced, but it doesn´t work to me.I did small changes in code, but nothing difficult. The only thing which is working is Enable/disable groupping. When I uncheck a layer, layer is still visible in ScheduleView. Am I doing something wrong in my code?

MainWindow.xaml

<Window x:Class="TestScheduleView.MainWindow"
        Title="MainWindow" Height="500" Width="800"
        xmlns:telerikScheduler="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.ScheduleView"
        xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls">
    <Window.Resources>
        <SolidColorBrush x:Key="MainBackground" Color="#FF000000" />
        <LinearGradientBrush x:Key="SubHeadingBackground" EndPoint="0.5,1" MappingMode="RelativeToBoundingBox"
                StartPoint="0.5,0">
            <GradientStop Color="#FF4B4B4B" Offset="1" />
            <GradientStop Color="#FF6E6E6E" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="SelectionOptionBackground" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FF1E1E1E" Offset="0" />
            <GradientStop Color="#FF040404" Offset="1" />
        </LinearGradientBrush>
        <SolidColorBrush x:Key="SelectionOptionBorderBrush" Color="#FF313132" />
        <Style x:Key="SelectionOptionStyle" TargetType="Border">
            <Setter Property="Background" Value="{StaticResource SelectionOptionBackground}" />
            <Setter Property="BorderBrush" Value="{StaticResource SelectionOptionBorderBrush}" />
            <Setter Property="BorderThickness" Value="1 0 1 1" />
            <Setter Property="MinHeight" Value="70" />
        </Style>
    </Window.Resources>
  
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="32" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="225" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Border Grid.RowSpan="2" Grid.ColumnSpan="2" telerikQuickStart:ThemeAwareBackgroundBehavior.IsEnabled="True" />
  
        <Border Background="#FF212121" Grid.RowSpan="2" />
  
        <Border Background="{StaticResource MainBackground}" Grid.ColumnSpan="2">
            <TextBlock Text="Grouping and Filtering"  FontFamily="Segoe UI"
                    HorizontalAlignment="Left" Foreground="#FFE5E2E2" Margin="13 0 0 0" FontSize="16" TextWrapping="Wrap"
                    VerticalAlignment="Center" />
        </Border>
  
        <StackPanel Grid.Row="1" Orientation="Vertical">
            <Border Background="{StaticResource SubHeadingBackground}" Height="32">
                <TextBlock Text="Select a Layer" TextWrapping="Wrap" FontSize="13" Foreground="#FFEBE9E9"
                        FontFamily="Segoe UI" VerticalAlignment="Center" Margin="13 0 0 0" />
            </Border>
            <Border Background="{StaticResource MainBackground}" Height="32">
                <CheckBox IsChecked="{Binding EnableGrouping}" Content="Enable Grouping"
                         Foreground="#FFA9A9A9" FontWeight="Normal"
                        Margin="13 0 0 0" VerticalAlignment="Center" />
            </Border>
  
            <Border Style="{StaticResource SelectionOptionStyle}" Height="32">
                <StackPanel Orientation="Horizontal" Margin="5">
                    <CheckBox IsChecked="{Binding ShowPresentationLayer}" Content="Fixed" IsEnabled="{Binding EnableGrouping}"
                              Foreground="#FFA9A9A9" VerticalAlignment="Center" Margin="10" Padding="10 0 0 0" />
                </StackPanel>
            </Border>
            <Border Style="{StaticResource SelectionOptionStyle}">
                <StackPanel Orientation="Horizontal" Margin="5">
                    <CheckBox IsChecked="{Binding ShowDataLayer}" Content="PeriodicFixed" IsEnabled="{Binding EnableGrouping}"
                              Foreground="#FFA9A9A9"  VerticalAlignment="Center" Margin="10" Padding="10 0 0 0"/>
                </StackPanel>
            </Border>
            <Border Style="{StaticResource SelectionOptionStyle}">
                <StackPanel Orientation="Horizontal" Margin="5">
                    <CheckBox IsChecked="{Binding ShowBusinessLayer}" Content="Periodical" IsEnabled="{Binding EnableGrouping}"
                              Foreground="#FFA9A9A9"  VerticalAlignment="Center" Margin="10" Padding="10 0 0 0"/>
                </StackPanel>
            </Border>
        </StackPanel>
  
        <telerikScheduler:RadScheduleView Grid.Column="1" Grid.Row="1" 
                                          SnapAppointments="True" 
                                          x:Name="radScheduler"
                AppointmentsSource="{Binding Appointments}" 
                GroupDescriptionsSource="{Binding GroupDescriptions}"
                ActiveViewDefinitionIndex="1">
  
            <telerikScheduler:RadScheduleView.ViewDefinitions>
                <telerikScheduler:DayViewDefinition GroupFilter="{Binding GroupFilter}" Orientation="Horizontal" DayStartTime="12:00:00" />
                <telerikScheduler:WeekViewDefinition GroupFilter="{Binding GroupFilter}" Orientation="Horizontal" DayStartTime="12:00:00" />
                <telerikScheduler:MonthViewDefinition GroupFilter="{Binding GroupFilter}" />
                <telerikScheduler:TimelineViewDefinition GroupFilter="{Binding GroupFilter}" />
            </telerikScheduler:RadScheduleView.ViewDefinitions>
  
  
            <telerikScheduler:RadScheduleView.ResourceTypesSource>
                <telerikScheduler:ResourceTypeCollection>
                    <telerikScheduler:ResourceType Name="Category">
                        <telerikScheduler:Resource ResourceName="Fixed" />
                        <telerikScheduler:Resource ResourceName="PeriodicFixed" />
                        <telerikScheduler:Resource ResourceName="Periodical" />
                    </telerikScheduler:ResourceType>
                </telerikScheduler:ResourceTypeCollection>
            </telerikScheduler:RadScheduleView.ResourceTypesSource>
        </telerikScheduler:RadScheduleView>
    </Grid>
</Window>

MainWindow.xaml.cs

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;
  
namespace TestScheduleView
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
  
            this.DataContext = new ViewModel();
        }
    }
}

ViewModel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Controls.ScheduleView;
using Telerik.Windows.Controls;
using System.ComponentModel;
  
namespace TestScheduleView
{
    class ViewModel : ViewModelBase
    {
        private bool showBusinessLayer = true;
        private bool showDataLayer = true;
        private bool showPresentationLayer = true;
        private bool enableGrouping = true;
        private GroupDescriptionCollection groupDescriptions;
        private Func<object, bool> groupFilter;
  
        public bool ShowBusinessLayer
        {
            get
            {
                return this.showBusinessLayer;
            }
            set
            {
                if (this.showBusinessLayer != value)
                {
                    this.showBusinessLayer = value;
                    this.OnPropertyChanged(() => this.ShowBusinessLayer);
                    this.UpdateGroupFilter();
                }
            }
        }
  
        public bool ShowDataLayer
        {
            get
            {
                return this.showDataLayer;
            }
            set
            {
                if (this.showDataLayer != value)
                {
                    this.showDataLayer = value;
                    this.OnPropertyChanged(() => this.ShowDataLayer);
                    this.UpdateGroupFilter();
                }
            }
        }
  
        public bool ShowPresentationLayer
        {
            get
            {
                return this.showPresentationLayer;
            }
            set
            {
                if (this.showPresentationLayer != value)
                {
                    this.showPresentationLayer = value;
                    this.OnPropertyChanged(() => this.ShowPresentationLayer);
                    this.UpdateGroupFilter();
                }
            }
        }
  
        public bool EnableGrouping
        {
            get
            {
                return this.enableGrouping;
            }
            set
            {
                if (this.enableGrouping != value)
                {
                    this.enableGrouping = value;
                    this.OnPropertyChanged(() => this.EnableGrouping);
  
                    this.UpdateGroupDescriptions();
                }
            }
        }
  
        public GroupDescriptionCollection GroupDescriptions
        {
            get
            {
                if (this.groupDescriptions == null)
                {
                    this.groupDescriptions = new GroupDescriptionCollection() { new DateGroupDescription() };
                    this.UpdateGroupDescriptions();
                }
                return this.groupDescriptions;
            }
        }
  
        public Func<object, bool> GroupFilter
        {
            get
            {
                return this.groupFilter;
            }
            private set
            {
                this.groupFilter = value;
                this.OnPropertyChanged(() => this.GroupFilter);
            }
        }
  
        private void UpdateGroupFilter()
        {
            this.GroupFilter = new Func<object, bool>(this.GroupFilterFunc);
        }
  
        private bool GroupFilterFunc(object groupName)
        {
            IResource resource = groupName as IResource;
  
            if (resource == null)
                return true;
  
            IEnumerable<string> enumerable = GetEnabledGroups();
  
            foreach (string str in enumerable)
            {
                if (str.ToLower().Equals(resource.ResourceName.ToLower()))
                    return true;
            }
  
            return false;
        }
  
        private ObservableAppointmentCollection appointments;
        public ObservableAppointmentCollection Appointments
        {
            get
            {
                return this.appointments;
            }
            set
            {
                this.appointments = value;
            }
        }
  
        public ViewModel()
        {
            appointments = new ObservableAppointmentCollection();
  
            Appointment appointment = new Appointment();
            appointment.Start = DateTime.Now;
            appointment.End = DateTime.Now.AddHours(1);
            appointment.Subject = "New appointment";
            Resource r = new Resource();
            r.ResourceName = "Periodical";
            r.ResourceType = "Category"; 
            appointment.Resources.Add(r);
            Appointments.Add(appointment); 
        }
  
        private IEnumerable<string> GetEnabledGroups()
        {
            List<string> enabledGroups = new List<string>();
  
            if (this.ShowPresentationLayer) enabledGroups.Add("Fixed");
            if (this.ShowDataLayer) enabledGroups.Add("PeriodicFixed");
            if (this.ShowBusinessLayer) enabledGroups.Add("Periodical");
  
            return enabledGroups;
        }
  
        private void UpdateGroupDescriptions()
        {
            if (this.EnableGrouping)
            {
                ResourceGroupDescription groupDescription = new ResourceGroupDescription();
                groupDescription.ResourceType = "Category";
                this.GroupDescriptions.Add(groupDescription);
            }
            else
            {
                this.GroupDescriptions.RemoveAll((GroupDescription g) => g is ResourceGroupDescription);
            }
        }
    }
}

Paolo
Top achievements
Rank 1
 answered on 04 Dec 2012
1 answer
120 views
Hi,

I am using a RadGridView control and I assign a List to ItemsSource propriety.
Now I want to modify the color of the cells of one column, depending on it content. So, if in a cell content is "X" I want to color with red, if it is "Y" I want to color with blue, ... (please see attachment)

Thanks
Vlad
Telerik team
 answered on 04 Dec 2012
1 answer
176 views
Hi,

I have a RadDataPager which shows in order to page a RadGridView content.
The PageSize is fixed, but I would like that it changes depending on height of a RadGridView, i.e., depending of screen resolution. The height for RadGridView is defined as "Auto", so I would like that the number of items that I have in each page is the maximum number of items that can feet without it has a scroll.

Any idea?

Rossen Hristov
Telerik team
 answered on 04 Dec 2012
2 answers
229 views
hi, what's the property to hide the grid on the diagram?

thanks!
Fabrizio
Top achievements
Rank 1
 answered on 04 Dec 2012
3 answers
287 views
Hi, was was wondering if it was possible to have a chart with a linear axis for both the x and y axis that behaves like the bar chart in that each value is drawn as a bar/line from the axis to the value?  The scatter point chart is the closest in behaviour to what I want, but instead of a single point, I need a line from the axis.

regards,
Eamon
Missing User
 answered on 04 Dec 2012
6 answers
1.3K+ views
Hi,

I have a TreeView with a ContextMenu associated with it. When the context menu pops pup I need to know what is the item under the mouse pointer. However, when I check the "SelectedItem" property, it is not the item which is under the mouse pointer. I'm thinking about a way to make the item selected when right-click is used. Currently it is being selected only when a left-click is performed.

Thank you,
Ruben
Pavel R. Pavlov
Telerik team
 answered on 04 Dec 2012
7 answers
204 views
I'm frustrated with the tree column for the GanttView as well as Cell templates within all columns.

I'd like to have the tree column be un-frozen, not necessarily be the first visible column, and not necessarily be bound to title.

I tried changing the MemberBinding of the TreeColumnDefinition to point to a different property but it still seems to go after the Title property. I tried adding a Cell Template similar to this:

<telerik:TreeColumnDefinition MemberBinding="{Binding WBS}" Header="WBS" ColumnWidth="60">
  <telerik:TreeColumnDefinition.CellTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding WBS}" />
    </DataTemplate>
  </telerik:TreeColumnDefinition.CellTemplate>
</telerik:TreeColumnDefinition>

But that binding was invalid. Not being able to access my data item from within a DataTemplate is a pretty bad thing in my opinion and a severe limitation of the control in its current form.

I don't like that the TreeColumn is frozen and leftmost and would like to be able to change this behavior. The frozen isn't as bad as the leftmost behavior. 

Is there any way in the current code to have the TreeColumn point at something other than Title? How do I get at my data item from within a DataTemplate? The data context doesn't appear to be correct.
Miroslav Nedyalkov
Telerik team
 answered on 04 Dec 2012
6 answers
211 views
Hello,

We are using Telerik RadControls for WPF Q3 2010. We have a RadGridView in which the user can edit the data displayed. The edit control for string columns is RadMaskedTextBox.

When I want to enter a @ character with AltGr+v using Hungarian keyboard layout, it seems a 'weird' paste operation (Ctrl+v) occurs: when the clipboard contains multi-line text, new rows are inserted in the grid, when single-line, nothing happens.

Also the AltGr+c (which is a & for hu-HU) wont work. Other key combinations which I've tested works fine.

I can reproduce this issue using the RadControls for WPF Demo -> GridView -> First Look example (where the cells are editable).

Thanks,
   Zoltan Tanczos
Josip
Top achievements
Rank 1
 answered on 04 Dec 2012
4 answers
266 views
Hi,

I use an Image that is shown when dragging:
args.DragVisual = new ContentControl { Content = MyImage, Width = 25, Height = 25 };
This image always shows up at a certain position relative to the cursor. Can I influence this position? I tried DragVisualOffset but - maybe I used it incorrect - that didn't result in a change of position. Thanks in advance, Vincent
Vincent
Top achievements
Rank 1
 answered on 04 Dec 2012
0 answers
196 views
Hi,

I've recently begun working on my first WPF application using Telerik's RadControls and I've run into a problem which I am unable to solve. I have a main RadGridView which has multiple levels of nested RadGridViews (3 nested gridviews in total). Each nested GridView relies on information from the parent in order to populate the columns and I do so by binding a method to the LoadingRowDetails event and pass that information to my ViewModel. When the nested gridview attempts to load the ObservableCollection, its Get method uses the retrieved information in order to execute an SQL query on the DB and populate the collection. 

My problem is that for some reason when I attempt to bind a method to the 3rd nested RadGridView, instead of working as the parents do, it throws an NullReferenceException (it doesn't even reach the method) upon attempting to expand just the first row.
I've read and searched everywhere for a solution, but to no avail.

I unfortunately cannot share my actual code, since my company prohibits it, but I hope this example is clear enough to perhaps allow for a solution.

<Grid>   
    <telerik:RadGridView x:Name="Tools" Marin="0" LoadingRowDetails="ToolsLoadingRowDetails" ItemsSource="{Binding Tools}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewToggleRowDetailsColumn />
            <telerik:GridViewDataColumn Header="Product Id" DataMemberBinding="{Binding Path=TypeOfTool}" Width="*"/>
            <telerik:GridViewDataColumn Header="Target market" DataMemberBinding="{Binding Path=TargetMarket}" Width="3*"/>
           </telerik:RadGridView.Columns>
           <telerik:RadGridView:RowDetailsTemplate>
               <DataTemplate>
                   <telerik:RadGridView  Marin="0" LoadingRowDetails="MoreInfoLoadingRowDetails" ItemsSource="{Binding Path=DataContext.MoreInfo, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}}}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
                       <telerik:RadGridView.Columns>
                           <telerik:GridViewToggleRowDetailsColumn />
                           <telerik:GridViewDataColumn Header="More Info" DataMemberBinding="{Binding Path=MoreInfo}" Width="*"/>
                       </telerik:RadGridView.Columns>
                          <DataTemplate>
                               <telerik:RadGridView Marin="0" LoadingRowDetails="DetailedInfoLoadingRowDetails" ItemsSource="{Binding Path=DataContext.DetailedInfo, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}, AncestorLevel=2}}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
                                   <telerik:RadGridView.Columns>
                                       <telerik:GridViewToggleRowDetailsColumn />
                                      <telerik:GridViewDataColumn Header="Detailed Info" DataMemberBinding="{Binding Path=DetailedInfo}" Width="*"/>
                                   </telerik:RadGridView.Columns>
                                       <DataTemplate>
                                           <telerik:RadGridView Marin="0" LoadingRowDetails="TargetInfoLoadingRowDetails" ItemsSource="{Binding Path=DataContext.TargetInfo, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}, AncestorLevel=3}}" IsReadOnly="True" RowHeight="45" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="True" ShowGroupPanel="False">
                                               <telerik:RadGridView.Columns>
                                                  <telerik:GridViewToggleRowDetailsColumn />
                                                  <telerik:GridViewDataColumn Header="Target Info" DataMemberBinding="{Binding Path=TargetInfo}" Width="*"/>
                                   </telerik:RadGridView.Columns>
                               </telerik:RadGridView>
                           </telerik:RadGridView.RowDetailsTemplate>
                       </telerik:RadGridView>
                   </DataTemplate>
               </telerik:RadGridView.RowDetailsTemplate>
           </telerik:RadGridView>
       </DataTemplate>
   </telerik:RadGridView.RowDetailsTemplate>
</telerik:RadGridView>

Again, I just wrote this by hand so it probably contains open/close tagging errors, but the overall idea should be understood.
The problematic event to bind to is the deepest one, in the example it is the "TargetInfo" GridView. 
The XAML works as long as I don't bind to the LoadingRowDetails event. The moment I add the binding, the code throws the NullReferenceException
open attempt to expand the first row.

I hope I've provided enough information regarding the problem.

Thanks

Dave
Top achievements
Rank 1
 asked on 03 Dec 2012
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?