Set Can Content Scroll of TaskBoard Columns
Environment
Product Version | 2025.3.813 |
Product | RadTaskBoard for WPF |
Description
Set the CanContentScroll
property of the ScrollViewer
element on the RadTaskBoard
control's columns.
Solution
The columns of the control are represented by the TaskBoardColumnContainer
element. It contains a ScrollViewer
in its ControlTemplate
, which has its CanContentScroll
property set to True.
To customize this, you can create a new attached property for the TaskBoardColumnContainer element and retrieve its ScrollViewer on the Loaded
event. To do so, you can use the ChildrenOfType extension method.
To set the attached property, create an implicit Style that targets the TaskBoardColumnContainer element.
Defining the attached property for setting the CanContentScroll of the ScrollViewer
public class TaskBoardColumnContainerExtensions
{
public static bool GetCanContentScroll(DependencyObject obj)
{
return (bool)obj.GetValue(CanContentScrollProperty);
}
public static void SetCanContentScroll(DependencyObject obj, bool value)
{
obj.SetValue(CanContentScrollProperty, value);
}
public static readonly DependencyProperty CanContentScrollProperty =
DependencyProperty.RegisterAttached("CanContentScroll", typeof(bool), typeof(TaskBoardColumnContainerExtensions), new PropertyMetadata (true, OnCanContentScrollChanged));
private static void OnCanContentScrollChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskBoardColumnContainer taskBoardColumnContainer = (TaskBoardColumnContainer)d;
taskBoardColumnContainer.Dispatcher.BeginInvoke(() =>
{
ScrollViewer scrollViewer = taskBoardColumnContainer.ChildrenOfType<ScrollViewer>().FirstOrDefault();
if (scrollViewer != null)
{
scrollViewer.CanContentScroll = (bool)e.NewValue;
}
});
}
}
Applying the attached property to the TaskBoardColumnContainer element
<!-- If NoXaml is used: BasedOn="{StaticResource TaskBoardColumnContainerStyle}" -->
<Style TargetType="taskboard:TaskBoardColumnContainer">
<Setter Property="local:TaskBoardColumnContainerExtensions.CanContentScroll" Value="False"/>
</Style>