Telerik Forums
UI for WPF Forum
1 answer
1.0K+ views
Hi,

I am using RadTreeView to show a Level Hierarchy. I have a textbox to enter search string and a "Search" button on the screen. When user enters the string and clicks "Search" button, the observable collection should be filtered and the Level that contains the entered string should be shown with their upper hierarchy only upto root.

I have made a class "Level" which I am using to implement Level hierarchy.

Here is the code for class

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections.ObjectModel;

 

namespace RadTreeViewSample

{

    class Level

    {

        public Level(int id, string name, Level parentLevel)

        {

            this.ID = id;

            this.Name = name;

            this.ParentLevel = parentLevel;

        }

 

        public int ID { get; set; }

        public string Name { get; set; }

        public Level ParentLevel { get; set; }

        public ObservableCollection<Level> ChildLevels { get; set; }

 

        public static ObservableCollection<Level> SampleLevelList(int level, Level parentOrg)

        {

            ObservableCollection<Level> orgList = new ObservableCollection<Level>();

            for (int i = 0; i < 5; i++)

            {

                Level org = new Level(i, "Level " + level.ToString() + "-" + i.ToString(), parentOrg);

                if (level > 0)

                    org.ChildLevels = SampleLevelList(level - 1, org);

                orgList.Add(org);

            }

            return orgList;

        }

    }

 

}

 

 

 

 






Here is the xaml

<
Window x:Class="RadTreeViewSample.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

        xmlns:telerikTV="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"

        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>

        <HierarchicalDataTemplate x:Key="items" ItemsSource="{Binding ChildLevels}">

            <TextBlock Text="{Binding Name}"/>

        </HierarchicalDataTemplate>

    </Window.Resources>

    <Grid>

        <Grid.RowDefinitions>

            <RowDefinition Height="auto"/>

            <RowDefinition />

        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>

            <ColumnDefinition />

            <ColumnDefinition Width="auto"/>

        </Grid.ColumnDefinitions>

        <TextBox x:Name="txtOrgname" Grid.Row="0" Grid.Column="0" Margin="5" />

        <Button x:Name="btnSearch" Content="Search" Width="80" Grid.Row="0" Grid.Column="1" Margin="5" Click="btnSearch_Click"/>

        <telerik:RadTreeView x:Name="rtvLevel" ItemTemplate="{StaticResource items}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5"/>

    </Grid>

</Window>

 

 

 



Here is my code-behind

 


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;

using System.Collections.ObjectModel;

 

namespace RadTreeViewSample

{

    /// <summary>

    /// Interaction logic for MainWindow.xaml

    /// </summary>

    public partial class MainWindow : Window

    {

        private ObservableCollection<Level> LevelList;

        public MainWindow()

        {

            InitializeComponent();

 

            ObservableCollection<Level> LevelList = Level.SampleLevelList(5, null);

            rtvLevel.ItemsSource = LevelList;

        }

 

        private void btnSearch_Click(object sender, RoutedEventArgs e)

        {

What should I write here to filter the LevelList, so that only element that contains search string are show

       in treeview with their upper hierarchy only upto root ?

        }

 

    }

}

 

 

 

 

Kiril Stanoev
Telerik team
 answered on 19 Oct 2010
3 answers
460 views
Hi, Is it possible to modify the content of the tooltip?
When hovering a chart bar, we would like to handle the OnTooltipOpening Event and insert an ItemsControl or other (grid, ListBox...) to show details of the data.

So far, I have been able to get the datapoint (related data) but the child element of the tooltip is not showing.

Is there a TooltipTemplate somewhere and I haven't seen it? Or is it called something else?
It would be better to define this template in XAML and the databinding/context on the TooltipOpening event for me.

Any suggestion?

Thanks
Vladimir Milev
Telerik team
 answered on 19 Oct 2010
3 answers
96 views

Hi,
What is  the maximum limit for ItemsPerPage. How do Carousel handles the view if there is more than 100 image items assigned to ItemsPerPage.

Regards,
Raj.
Maya
Telerik team
 answered on 19 Oct 2010
1 answer
64 views
Hi,

I have a use case whereby I want to fix the first two columns in the RadGridView and make the rest scrollable.
What is the best possible way to achieve this?

Thanks,
Farhan
Maya
Telerik team
 answered on 19 Oct 2010
2 answers
131 views
I am trying to implement the SelectionChanged event on the RadGridView. In that event, I want to collapse every row in the GridView except that one row that happens to be selected. However, I can't seem to figure out how to find the rows themselves to set the IsExpanded property to true or false. The items collection is available, but it only gives me access to the bound collection and not the GridViewRow items. How do I get the rows collection?
Ristogod
Top achievements
Rank 2
 answered on 18 Oct 2010
6 answers
142 views
I'd like to set my columns to Auto for size, however I do not want to allow scrolling of any kind, nor should the column on the right dissapear off the right hand side.  I was hoping this property was a cumulative for all columns but it appears it's for each column.  Is there any way to make the columns size automatically but truncate data to fit in the screen they are given?
Paul
Top achievements
Rank 1
 answered on 18 Oct 2010
1 answer
126 views
I'm having an issue with the RadDatePicker which sounds very much like this topic


Do I need a converter of some type ?

I replaced the radDatePicker with a DatePicker and everything worked as expected, I'm thinking that there is somekind of bug or I need a converter.
Kaloyan
Telerik team
 answered on 18 Oct 2010
1 answer
157 views
In the DateTimePicker, if the user enters an 11 first, then I would like to assume that they mean November and automatically move them to the day section. Similarly if the user enters a 5 in the day section I'd like to move them to the year section since 5x is not a valid day choice. Additionally, I would like to have the text box section of the DateTimePicker set up with a mask. So that when the user starts typing they see 00/00/0000 and as they type they overwrite the zeros so that there are 8 numbers and two slashes in the DateTimePicker textbox at all times. Is this possible with the DateTimePicker? 
Kaloyan
Telerik team
 answered on 18 Oct 2010
1 answer
62 views
Hi

I have a requirement where I need to show tooltip tip for the month and year in the header of calendar. I mean the text which says October - 2010 i need to apply a tooltip based on the month. Is it currently supported in the control if so how.

Regards
Kiran
Kaloyan
Telerik team
 answered on 18 Oct 2010
6 answers
86 views

I have some aggregrate functions on my gridview like this
 groupview = new QueryableCollectionView(MyListGrid.Items);
                    if (MyListGrid.GroupDescriptors.Count > 0)
                        MyListGrid.GroupDescriptors.Clear();
                    var descriptor = new GroupDescriptor() { Member = "Status" };
                    descriptor.AggregateFunctions.Add(new CountFunction());
                    this.MyListGrid.GroupDescriptors.Add(descriptor);

and I get the following exception at descriptor.AggregateFunctions.Add(new CountFunction());

{"Unable to cast object of type 'Telerik.Windows.Data.QueryableCollectionViewGroup' to type 'Telerik.Windows.Data.AggregateFunctionsGroup'."}
Xaria D
Top achievements
Rank 1
 answered on 18 Oct 2010
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
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?