Search code examples
c#wpftelerikgantt-chart

Telerik WPF RadGanttView sections width


I need to stretch a diagram and a grid in Telerik WPF RadGanttView control for the full windows width. But the diagram width stays 336 units anyway and 105 units for the grid. No property affects it. The code is:

<telerik:RadGanttView Grid.Row="1"                  HorizontalAlignment="Stretch" Margin="8,0,6,20" VerticalAlignment="Stretch" 
             TasksSource="{Binding GanttTasks}" Background="{DynamicResource backgroundBrush}" BorderBrush="{DynamicResource BorderBrush}"/>

Tell me please how can I increase the real width to the full window.


Solution

  • To provide a little more info for anyone else dealing with this...

    • The RadGanttView defaults to only displaying 7 days of information
    • This is defined as the VisibleRange of the control
    • The TimeRuler part of the control only expands to be wide enough to display the VisibleRange
    • If the VisibleRange is wider than the available display area, you can horizontally scroll, as expected and everything looks good
    • If the VisibleRange is narrower than the available display area, you wind up with a blank space to the right of the TimeRuler part of the control - which looks particularly bad when the window is maximized

    To make the TimeRuler part of the control expand to use the available display area, you have to set the VisibleRange property on the control to a value that is high enough to extend beyond the available display area (e.g. 30+ days, etc.)

    You can add a VisibleRange property to your view model and set the Start/End dates in the view model constructor (or wherever it makes sense for you):

    VisibleRange = new VisibleRange
    {
        Start = DateTime.Today,
        End = DateTime.Today.AddDays(60)
    };
    

    And then you can bind the VisibleRange property on the RadGanttView to the VisibleRange property you just added to your view model:

    <telerik:RadGanttView x:Name="GanttView" TasksSource="{Binding Tasks}" VisibleRange="{Binding VisibleRange}" />