Telerik Forums
UI for WPF Forum
1 answer
114 views
Hello
How to remove the visibility of lines in specific nodes of a RadTreeView(not root)
Martin Ivanov
Telerik team
 answered on 13 May 2021
2 answers
211 views

Hi Team,

We are facing the below exception in our applicaiton. Currently we are using version 4.0 telerik radtreeview in our application . can you please confirm whether it is related version issue or any other reason and  How to resolve this issue?

Stack Trace:
Timestamp: 3/23/2021 15:58:17           Message: HandlingInstanceID: c392afd7-c81e-4acf-86d3-2bc248a1b9ab
An exception of type 'System.NullReferenceException' occurred and was caught.
-----------------------------------------------------------------------------
03/23/2021 11:58:17
Type : System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : AUID = 724 - Object reference not set to an instance of an object.
Source : PresentationFramework
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void Remove(System.Windows.Controls.Primitives.GeneratorPosition, Int32, Boolean)
HResult : -2147467261
Stack Trace :    at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
   at Telerik.Windows.Controls.TreeView.TreeViewPanel.CleanupRange(IList children, IItemContainerGenerator generator, Int32 startIndex, Int32 count)
   at Telerik.Windows.Controls.TreeView.TreeViewPanel.CleanupContainers(Int32 firstViewport, ItemsControl itemsControl)
   at Telerik.Windows.Controls.TreeView.TreeViewPanel.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.ItemsPresenter.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 Telerik.Windows.Controls.RadTreeViewItem.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Telerik.Windows.Controls.TreeView.TreeViewPanel.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.ItemsPresenter.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.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 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.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.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.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.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 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)

 

Thanks,

Srinivasan

Uma
Top achievements
Rank 1
 answered on 23 Apr 2021
22 answers
1.2K+ views
Hello!

if I set an RadTreeViewItem to  ".Visibility = Visibility.Collapsed" or ".Visibility = Visibility.Hidden", the item is not visible BUT it stil takes space in the triewview (as a empty row).

Is this a bug, or how do I make an item invisible by code?

Petar Mladenov
Telerik team
 answered on 20 Apr 2021
9 answers
794 views
Hi. I'm generating a RadTreeView and its items through WPF data binding using a HierarchicalDataTemplate. So when I add a new item to the collection the RadTreeView is looking at, and I set the selected item to that newly added object, I try to get the selected container, but it's null. This is my code:

private void OnAddFolderClicked(object sender, RoutedEventArgs e) 
        { 
            IFolderContainer container = (sender as MenuItem).DataContext as IFolderContainer ?? null

            Folder folder = new Folder() { Name = "Folder" }; 
 
            container.AddFolder(folder); 
 
            treeViewExplorer.SelectedItem = folder; 
 
            folder.IsNodeInEditMode = true
 
            RadTreeViewItem selectedItem = treeViewExplorer.SelectedContainer; // this is null even though I set the SelectedItem = folder
        } 

What I want to do is to set focus on it, so if the user clicks F2 right away after creating it, it can go into edit mode, right now the object looks selected, but hitting F2 doesn't do anything unless deselect it, and select it again.

Thanks!
Dinko | Tech Support Engineer
Telerik team
 answered on 20 Apr 2021
1 answer
141 views
I am trying to use a tree view for a situation where there may or may not be children. When there are no children, the list is effectively flat, and it doesn't look right to see a big space to the left of the items where the expander would go. I tried to set the expander visual style so that the button is collapsed, but it looks like there is a minimum width on the ListRootContainer. Is there any way to do this without replacing the entire control template?
Petar Mladenov
Telerik team
 answered on 30 Mar 2021
9 answers
1.1K+ views
I have a treeview with a hierarchical template and I'm using mvvm. So far I have not been able to get the command binding correct for the context menu. It's trying to bind to the item's datacontext, but I want to bind it to the datacontext of the treeview. I have tried several approaches including relativesource, etc. Any help would be appreciated.

 
Dinko | Tech Support Engineer
Telerik team
 answered on 29 Mar 2021
2 answers
896 views

Hello,

I have a treeView and I want to bind each item command, command parameter and IsEnabled properties. If I bind just the IsEnabled property it works, but if I add the command binding, the command works, but IsEnabled binding breaks.

I use the following code:

<telerik:RadTreeView ItemsSource="{Binding TreeViewModel.Categories}"
                                         Grid.Row="0">
                        <telerik:RadTreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding SubCategories}">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock VerticalAlignment="Center" Text="{Binding Name}" />
                                </StackPanel>
                            </HierarchicalDataTemplate>
                        </telerik:RadTreeView.ItemTemplate>
                        <telerik:RadTreeView.ItemContainerStyle>
                            <Style TargetType="telerik:RadTreeViewItem" BasedOn="{StaticResource RadTreeViewItemStyle}">
                                <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
                                <Setter Property="Command" Value="{Binding Path=DataContext.GoToTabCommand, RelativeSource={RelativeSource AncestorType=telerik:RadWindow}}" />
                                <Setter Property="CommandParameter" Value="{Binding Name}" />
                            </Style>
                        </telerik:RadTreeView.ItemContainerStyle>
                    </telerik:RadTreeView>

 

 

How can I make both bindings to work?

Remus
Top achievements
Rank 1
Veteran
 answered on 22 Mar 2021
3 answers
762 views

I am using the "UI for WPF Q1 2016" release, WPF, .NET Framework 4.6.1, Windows 10 and C#.

I am trying to implement drag and drop within a single RadTreeView. The default drag visual has a great structure, but has some problems for me. (The background of the drag item is dark and I can't read the dragged item's name, and the drop tooltip seems to be calling ToString() on my viewmodel, and that is not the text that I want.)

Researching, the page "Customize the TreeViewDragVisual" (https://docs.telerik.com/devtools/wpf/controls/radtreeview/how-to/customize-treeviewdragvisual)
tells me to derive from RadTreeView and to modify the template. But I am using NoXaml binaries and this page indicates that I must set the control template in app.xaml. Therefore it will apply to all RadTreeViews, and this doesn't seem like what I want to do.

Then I find the forum post on modifying the tooltip (https://www.telerik.com/forums/treeview---how-to-modify-the-drag-drop-drag-tooltip-target-part)
which points me at the DragDropManager. The manager has a "Set Drag Visual" topic (https://docs.telerik.com/devtools/wpf/controls/dragdropmanager/how-to/dragdrompmanager-howto-set-drag-visual) which says to handle DragDropManager.AddDragInitializeHandler and create a new drag visual in
the handler. This seems better than modifying app.xaml.

Also DragDropManager has the topic "Customizing the DragVisual" (https://docs.telerik.com/devtools/wpf/controls/dragdropmanager/behaviors/customizingdragvisual) which talks about implementing IDragVisualProvider. But the example is for ListBox and I'm using a RadTreeView.

So I'm all kinds of confused.

First, I need to fix the drag visual. I like the Drop Preview Line, the Drag Preview, and the Drag Tooltip parts. I need to change the Drag Preview and the Drag Tooltip.

Then I need to handle the "drop", which I think is done by attaching my own handler to DragDropManager.Drop event.

Thanks for any help.

-John.


Dilyan Traykov
Telerik team
 answered on 05 Mar 2021
3 answers
188 views

Hi

 

I tried the dark Fluent style for RadTreeView but it didn't work well.

where is the problem from?

Look at the pictures

Vicky
Telerik team
 answered on 24 Feb 2021
1 answer
601 views

Hello,

we're currently updating our application to use Telerik components in order to make use of implicit styling.
I'm making good progress so far but am stuck at this one.

We're currently using the Office2019 theme in the Light color variation.
The problem I'm facing is with the selection of a TreeViewItem and the involved change of the Foreground color that goes along with it.

For TreeViewItems that use a string as a header this works just fine. The item i selected, the Background changes to blue and the Foreground to white. Perfetly readable.

However if I use a grid (containing a TextBlock) as the Header the foreground of the TextBlock remains black and does not change to white.

I tried binding the Foreground color of the TextBlock to the Foreground color of the parent TreeViewItem like so:

Binding binding = new Binding("Foreground");
binding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(RadTreeViewItem), 1);
tb.SetBinding(TextBlock.ForegroundProperty, binding);

 

However this does not work. Possible because the Foreground property of the TreeViewItem is never changed, but only the Foreground property of the header:

<!-- IsSelected general setters -->
<Trigger Property="IsSelected" Value="True">
    <Setter TargetName="Header" Property="Foreground" Value="{telerik1:Office2019Resource ResourceKey=CheckedForegroundBrush}"/>
    <Setter TargetName="BorderVisual" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(helpers:ThemeHelper.CheckedBrush)}"/>
</Trigger>

 

I tried to add another setter to this trigger and set the Foreground property of the TreeViewItem. This kind of works, but unfortunately propagates through all child items of a TreeViewItem.

Any suggestions on how my desired behaviour could be implemented?

Vladimir Stoyanov
Telerik team
 answered on 08 Dec 2020
Narrow your results
Selected tags
Tags
+112 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?