I want to use a RadTreeListView but the hierarchy does not contain children of the same type. Can I achieve this using RadTreeListView and have different properties at each hierarchy level?
Thank you!
Hello,
I am using a RadTreeView component in a WPF application that looks like in the following photo. The hierarchy is: a Category can contain a list of SubCategories and a SubCategory contains a List of Activities that have some properties. I would like to transform my RadTreeView into a RadTreeListView or RadGridVew in order to beneficiate from SelectionUnit property and the navigation between cells from the keyboard but I could not find anything that meets by needs:
a component with cells only on the last level of the hierarchy, to be able to select a cell and edit it and, if possible, to have a tabular header with details from the last level of the hirarchy.
Thank you!
Hi,
I am using <telerik:RadTreeListView> and the scroll functionality does not work. this is how my code looks like:
<UserControl x:Class="WISN.Windows.Survey.FacilityStaffControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:WISN.Windows.Survey.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<telerik:RadTreeListView x:Name="stufftreeListView" AutoGenerateColumns="False"
AutoExpandItems="True" GroupRenderMode="Flat" CanUserDeleteRows="False"
ItemsSource="{Binding AllStaffByType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }">
<telerik:RadTreeListView.ChildTableDefinitions>
<telerik:TreeListViewTableDefinition ItemsSource="{Binding StaffCategories,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></telerik:TreeListViewTableDefinition>
</telerik:RadTreeListView.ChildTableDefinitions>
<telerik:RadTreeListView.Columns>
<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsSelected}" AutoSelectOnEdit="True" EditTriggers="CellClick">
<telerik:EventToCommandBehavior.EventBindings>
<telerik:EventBinding Command="{Binding CustomCommandCommand}" EventName="MouseLeftButtonDown" />
</telerik:EventToCommandBehavior.EventBindings>
</telerik:GridViewCheckBoxColumn>
<telerik:GridViewDataColumn IsReadOnly="True" DataMemberBinding="{Binding Name}" Header="Stuff"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding AnnualSalary}" Header="Annual Salary"></telerik:GridViewDataColumn>
</telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>
</UserControl>
I really do not know how to fix it.
Thanks
Hi,
I wanted to use "search as you type" functionality (http://docs.telerik.com/devtools/wpf/controls/radgridview/features/search-as-you-type.html) in a TreeListView, but looks like it doesn't work for it even though it's inherited from GridView.
I tried it on a new blank project and confirmed my suspicion:
<
telerik:RadTreeListView
ShowSearchPanel
=
"True"
/>
doesn't show a search panel, but
<
telerik:RadGridView
ShowSearchPanel
=
"True"
/>
works without any issues.
Is this intended behaviour, or can we hope for a fix?
Thank you.
A list is to be displayed using the RadTreeListView. It should be possible to add a single element or to delete several selected elements. As soon as a new element is added, all other elements should be deselected and the new element should be selected.
The problem is that if a certain number of elements is deleted, afterwards just as many newly added elements are automatically deselected, although they were previously explicitly selected programmatically.
Example with test application
Initial state:
→ Click "Add" to add a new element:
→ Click "Delete" to delete selected element (for simplicity the automatically selected element just added is used):
→ Click "Add" to add a new element:
Element 4 should now be selected.
→ Click "Add" to add a new element:
Now it works again as expected.
The same behavior can be replicated with deleting multiple elements. Afterwards, exactly this number of then newly added elements are deselected, although they should be selected. After that the behavior is as expected again.
View
<StackPanel>
<Button Click="Add_Button_Click">Add</Button>
<Button Click="Delete_Button_Click">Delete</Button>
<telerik:RadTreeListView ItemsSource="{Binding VM.Elements}"
SelectionMode="Multiple"
IsSynchronizedWithCurrentItem="False"
RowIndicatorVisibility="Collapsed"
>
<telerik:RadTreeListView.RowStyle>
<Style TargetType="{x:Type telerik:TreeListViewRow}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
</Style>
</telerik:RadTreeListView.RowStyle>
</telerik:RadTreeListView>
</StackPanel>
CodeBehind
public partial class MainWindow : Window
{
public ViewModel VM { get; set; }
public MainWindow()
{
InitializeComponent();
VM = new ViewModel();
DataContext = this;
}
private void Add_Button_Click(object sender, RoutedEventArgs e)
{
VM.AddNewData();
}
private void Delete_Button_Click(object sender, RoutedEventArgs e)
{
VM.Elements.RemoveAll(x => x.IsSelected);
}
}
ViewModel
public class ViewModel
{
public ObservableCollection<Data> Elements { get; set; } = new ObservableCollection<Data>();
public ViewModel()
{
Enumerable.Range(0, 3).ForEach(_ => AddNewData());
Elements.CollectionChanged += Data_CollectionChanged;
}
public void AddNewData()
{
Elements.Add(new Data());
}
private void Data_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
Elements.ForEach(x => x.IsSelected = false);
e.NewItems?.OfType<Data>().ForEach(x => x.IsSelected = true);
}
}
public class Data : INotifyPropertyChanged
{
static private int counter = 0;
public event PropertyChangedEventHandler? PropertyChanged;
private bool isSelected = false;
public bool IsSelected
{
get
{
return isSelected;
}
set
{
isSelected = value;
OnPropertyChanged(nameof(IsSelected));
}
}
public int Id { get; set; } = counter++;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Any idea for object reference not set to an instance of an object error?
Error stack trace as below:
StackTrace -
at Telerik.Windows.Controls.GridView.GridViewRow.ApplyHierarchyExpandButtonStyle()
at Telerik.Windows.Controls.GridView.GridViewDataControl.ApplyRowStyle(GridViewRow row)
at Telerik.Windows.Controls.GridView.GridViewDataControl.PrepareContainerForItemOverride(DependencyObject element, Object item)
at Telerik.Windows.Controls.RadTreeListView.PrepareContainerForItemOverride(DependencyObject element, Object item)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.PrepareContainer(Object row, IVirtualizedContainer container)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RealizeRows(Int32 startIndex, Int32 endIndex, Double& verticalOffset, HashSet`1& realizedRows)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.MeasureOverride(Size availableSize)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
at Telerik.Windows.Controls.GridView.GridViewScrollViewer.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Window.MeasureOverrideHelper(Size constraint)
at System.Windows.Window.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Hi,
I am using a TreeListView to display financial data (element with costs per month) with sub-totals as the parent rows. The data structure is thus homogenous and a good fit for the TreeListView. The binding and data work perfectly, but now I would like to refine the styling to show a greater contrast between parent and child (e.g. make sub-total rows bold). Is there an simple way to do this?
I have the following ContexMenu:
Which has the following xaml:
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu Opened="RadContextMenu_Opened">
<telerik:RadMenuItem Header="Add" Command="{Binding AddInstance}" IsEnabled="{Binding EpmModelEditModeEnabled}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItem}"
Visibility="{Binding EnableEditMode, Converter={StaticResource boolToVisibilityConverter}}"/>
<telerik:RadMenuItem Header="Rename (F2)" Click="RenameItemMenu_Click" IsEnabled="{Binding EpmModelEditModeEnabled}"
Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems, Converter={StaticResource canRenameModelVisibilityConverter}}"/>
<telerik:RadMenuItem Header="Delete" Command="{Binding DeleteObject}" IsEnabled="{Binding EditModeEnabled}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems}"/>
<telerik:RadMenuItem Header="Create Chart Analysis" Command="{Binding CreateChart}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems}"/>
<telerik:RadMenuItem Header="Create Dataset Analysis" Command="{Binding CreateDataset}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadContextMenu}}, Path=UIElement.SelectedItems}"/>
<telerik:RadMenuItem x:Name="ColumnsMenu" Header="Columns">
<telerik:RadMenuItem.ItemTemplate>
<HierarchicalDataTemplate>
<MenuItem Header="{Binding Header}" IsCheckable="True" IsChecked="{Binding IsVisible, Mode=TwoWay}"/>
</HierarchicalDataTemplate>
</telerik:RadMenuItem.ItemTemplate>
</telerik:RadMenuItem>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
I need to know how do i change the size of the internal selection (in blue) to match the size of the external selection (in yellow), because when i click in the external selection the context menu closes.
At least, if it is not possible to change the size of the internal selection, i need that the context menu does not close when the external selection is clicked (adding StaysOpenOnClick="True" in the MenuItem inside of the <HierarchicalDataTemplate> does not work).
I have TreeLinesVisibility="Visible" on my TreeListView, as in the XAML snippet below.
<telerik:RadTreeListView x:Name="NEWCollectionControl" Grid.Row="1" EnableLostFocusSelectedState="False" ShowColumnHeaders="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadOutlookBar}}, Path=DataContext.Controller.ShowTreeHeader, Mode=TwoWay}" GridLinesVisibility="None" RowIndicatorVisibility="Collapsed" SelectionUnit="FullRow" ColumnWidth="*" TreeLinesVisibility="Visible" AutoExpandItems="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadOutlookBar}}, Path=DataContext.Controller.TreeViewAutoExpand, Mode=TwoWay}" AutoGenerateColumns="False" ItemsSource="{Binding Items}" IsExpandedBinding="{Binding IsExpanded, Mode=TwoWay}" SelectedCellsChanging="NEWCollectionControl_SelectedCellsChanging" DataLoaded="NEWCollectionControl_DataLoaded" Initialized="NEWCollectionControl_Initialized" SelectionChanged="NEWCollectionControl_SelectionChanged">
<telerik:RadTreeListView.ChildTableDefinitions>
<telerik:TreeListViewTableDefinition ItemsSource="{Binding Items}" />
</telerik:RadTreeListView.ChildTableDefinitions>
<telerik:RadTreeListView.Columns>
<telerik:GridViewImageColumn IsVisible="{Binding Controller.UseTreeViewIcons}" DataMemberBinding="{Binding Image}" TextAlignment="Left" ImageHeight="12" ImageWidth="{Binding ImageWidth}" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Translation.CurrentTranslation}" MinWidth="200" Header="{Binding Controller.PSRDictionary.Collection.CurrentTranslation}" />
</telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>
However, the GridViewImageColumn, which was added later in order to allow for some icons to the side of the TreeListView, is causing elements of the 3rd hierarchy level onwards to not have those lines. The behaviour can be seen in the image below, and it will happen regardless if the column is visible or not.
I have tried to mess with many of the properties on these elements but to no success.