Telerik Forums
UI for WPF Forum
1 answer
573 views
Hello,

I have a fairly simple tree, but it may contain thousands of items in 5 or 6 levels of depth.  The data collection is bound in MVVM and exists in the view model.  I created a context menu on right click that allows the user to Expand All for a single node, which could potentially open hundreds of child nodes.  When the expand command is executed, the collection is traversed and elements are changed to IsExpanded = true.

What I notice is that my view model command executes very quickly, but then the actual tree control spends quite a long time initializing the items and displaying the levels (can be 30 seconds or longer).  I guess I can live with the long wait, but how do I present and clear a busy indicator when control is lost to the Telerik threads?  Trying to set the busy indicator around the view model command only lasts for a second.

Are there other options for a faster or more visual response from the tree control?

The tree:
<HierarchicalDataTemplate x:Key="TreeObjectTemplate" ItemContainerStyle="{StaticResource containerStyle}" ItemsSource="{Binding ChildNodes}">
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding DisplayName}" />
    </StackPanel>
</HierarchicalDataTemplate>
 
        <telerik:RadTreeView Grid.Row="0" x:Name="tvTree" ItemTemplate="{StaticResource TreeObjectTemplate}"
                        Margin="0,8,0,4" VerticalAlignment="Top" Padding="0,2,0,10"
                        IsSingleExpandPath="False" IsLineEnabled="True" ExpanderStyle="{DynamicResource ExpanderStyle}"
                        SelectionMode="Single" IsEditable="False" IsDragDropEnabled="False" ItemContainerStyle="{StaticResource containerStyle}"
                        ItemsSource="{Binding tvTreeData}"
                        SelectedItem="{Binding tvSelectedItem, Mode=TwoWay}"
                        MouseRightButtonDown="treeView_MouseRightButtonDown">
            <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu>
                    <telerik:RadMenuItem Header="Expand All Levels" Command="{Binding ExpandCommand}"/>
                    <telerik:RadMenuItem Header="Collapse All Levels" Command="{Binding CollapseCommand}"/>
                </telerik:RadContextMenu>
            </telerik:RadContextMenu.ContextMenu>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="PreviewUnselected">
                    <Command:EventToCommand Command="{Binding Path=PreviewUnselectedCommand, Mode=OneWay}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
                <i:EventTrigger EventName="PreviewSelected">
                    <Command:EventToCommand Command="{Binding Path=PreviewSelectedCommand, Mode=OneWay}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </telerik:RadTreeView>

Expand Command:
private void ExpandAllChildren(MyTreeNode node, bool bExpandOrCollapse)
{
 
    foreach (MyTreeNode childNode in node.ChildNodes)
    {
        ExpandAllChildren(childNode, bExpandOrCollapse);
    }
 
    if (node.ChildNodes.Count > 0)
        node.IsExpanded = bExpandOrCollapse;
}
 
private RelayCommand _expandCommand;
public ICommand ExpandCommand
{
    get
    {
        if (_expandCommand == null)
        {
            _expandCommand = new RelayCommand(() =>
            {
                try
                {
                    UICursor = Cursors.Wait;
                    ExpandAllChildren(tvSelectedItem, true);
                }
                catch
                {
 
                }
                finally
                {
                    UICursor = Cursors.Arrow;
                }
            });
        }
 
        return _expandCommand;
    }
}

Thanks for any help.  Bob C.
Zarko
Telerik team
 answered on 11 May 2012
5 answers
81 views
i want to create manual spacing and overlapping of characters is this possible?

i have seen inside some application that the user can change the position of the character with sliders
one for x-axis and one for y-axis.

is this possible ?and how

 
Ivailo Karamanolev
Telerik team
 answered on 11 May 2012
1 answer
75 views
I have data bound to the ItemSource on a RadColumnSparkline within a RadTimeBar which displays fine on a usercontrol.  However, the issue comes in with new visual rendering where the property on the viewmodel is set (for the ItemSource on the RadColumnSparkline) before the usercontrol is loaded.  The binding between the viewmodel and view should be working on both scenarios?
Tsvetie
Telerik team
 answered on 11 May 2012
3 answers
140 views

I’ve problems binding an ObservableCollection<ISpatial> SpatialPolyItemCollection as Source in SqlGeospatialDataReader.

Nothing shows up in the map.

ISpatial is an Interface for a class Spatial containing Wkt to represent the polygon.

<telerik:InformationLayer x:Name="spatialPolyLayer">

   <telerik:InformationLayer.Reader>

        <telerik:SqlGeospatialDataReader x:Name="GeoReader" PreviewReadCompleted="PreviewReadCompleted"

Source="{Binding SpatialPolyItemCollection}"  GeospatialPropertyName="Wkt"      ToolTipFormat="Navn">

                    </telerik:SqlGeospatialDataReader>

       </telerik:InformationLayer.Reader>

</telerik:InformationLayer>

I can make it work in code behind by adding GeoReader.Source = SpatialPolyItemCollection.

Any Ideas how I can make this binding work without the code behind line?

I know that my collection is valid because it works fine if I use the same collection inside a GridView

<telerik:RadGridView x:Name="gridGeometriView"   SelectionMode="Extended"

                                      ItemsSource="{Binding SpatialPolyItemCollection}" FrozenColumnCount="2" SelectionChanged="GridViewSelectionChanged"/>

Evgenia
Telerik team
 answered on 11 May 2012
1 answer
122 views
I have modified some code so that you can get the Next & Previous Annotations ONLY if they exist on the same line as the caret.


Get Previous Same Line Annotation:
public static T GetPreviousSameLineAnnotationRangeStart<T>(this RadDocument document) where T : AnnotationRangeStart
{
    //Document caret position
    DocumentPosition caretPosition = new DocumentPosition(document.CaretPosition);
    //Caret Line Info
    ParagraphLineInfo caretLineInfo = caretPosition.GetCurrentInlineBox().LineInfo;
 
    //Next Annotation LineInfo variable
    ParagraphLineInfo previousAnnotationLineInfo = null;
 
 
    if (!document.Selection.IsEmpty)
    {
        document.CaretPosition.MoveToPosition(document.Selection.Ranges.Last.StartPosition);
    }
 
 
    InlineLayoutBox inlineLayoutBox = document.CaretPosition.GetCurrentInlineBox();
    do
    {
        inlineLayoutBox = (InlineLayoutBox)DocumentStructureCollection.GetPreviousElementOfType(inlineLayoutBox, typeof(AnnotationMarkerLayoutBox));
    }
    while (inlineLayoutBox != null && !(inlineLayoutBox.AssociatedInline is AnnotationRangeStart));
 
 
    if (inlineLayoutBox == null)
    {
        return null;
    }
    else
    {
        //Get next annotation lineinfo if next annotation exists
        previousAnnotationLineInfo = inlineLayoutBox.LineInfo;
    }
 
 
    //Compare caret & next annotation lines
    if (previousAnnotationLineInfo != caretLineInfo)
    {
        return null;
    }
 
 
    return inlineLayoutBox.AssociatedInline as T;
}

Get Next Same Line Custom Annotation:
public static T GetNextSameLineAnnotationRangeStart<T>(this RadDocument document) where T : AnnotationRangeStart
{
    //Document caret position
    DocumentPosition caretPosition = new DocumentPosition(document.CaretPosition);
 
    //Caret Line Info
    ParagraphLineInfo caretLineInfo = caretPosition.GetCurrentInlineBox().LineInfo;
 
    //Next Annotation LineInfo variable
    ParagraphLineInfo nextAnnotationLineInfo = null;
 
     
 
    if (!document.Selection.IsEmpty)
    {
        document.CaretPosition.MoveToPosition(document.Selection.Ranges.Last.EndPosition);
    }
 
    InlineLayoutBox inlineLayoutBox = document.CaretPosition.GetCurrentInlineBox();
    while (inlineLayoutBox != null && !(inlineLayoutBox.AssociatedInline is AnnotationRangeStart))
    {
        inlineLayoutBox = (InlineLayoutBox)DocumentStructureCollection.GetNextElementOfType(inlineLayoutBox, typeof(AnnotationMarkerLayoutBox));
    }
 
 
    if (inlineLayoutBox == null)
    {
        return null;
    }
    else
    {
        //Get next annotation lineinfo if next annotation exists
        nextAnnotationLineInfo = inlineLayoutBox.LineInfo;
    }
 
 
    T annotationRangeStart = inlineLayoutBox.AssociatedInline as T;
    if (annotationRangeStart == null)
    {
        return null;
    }
 
    //Compare caret & next annotation lines
    if (nextAnnotationLineInfo != caretLineInfo)
    {
        return null;
    }
 
    return annotationRangeStart;
}


Here are some examples on how you can use these (note that the Get Next & Previous methods above are in a class file named RadDocumentExtensions. Change this to whatever your class name is):

Previous Same Line Annotation (change the last message box details to suit your custom annotation properties):
SemanticRangeStart sameLinePreviousAnnotation = RadDocumentExtensions.GetPreviousSameLineAnnotationRangeStart<SemanticRangeStart>(this.radRichTextBox.Document);
 
if (sameLinePreviousAnnotation == null)
{
    MessageBox.Show("No previous annotations");
}
else
{
    MessageBox.Show("Name: " + sameLinePreviousAnnotation.Product.Name.ToString() + "\n\nHas Child: " + sameLinePreviousAnnotation.Product.HasChild.ToString());
}


Next Same Line Annotation (change the last message box details to suit your custom annotation properties):

SemanticRangeStart sameLineNextAnnotation = RadDocumentExtensions.GetNextSameLineAnnotationRangeStart<SemanticRangeStart>(this.radRichTextBox.Document);
 
if (sameLineNextAnnotation == null)
{
    MessageBox.Show("No next annotations");
}
else
{
    MessageBox.Show("Name: " + sameLineNextAnnotation.Product.Name.ToString() + "\n\nHas Child: " + sameLineNextAnnotation.Product.HasChild.ToString());
}



Thought I should share this with everyone. There's no point all of us trying to do the same job twice!

Thanks,

Rob
Ivailo Karamanolev
Telerik team
 answered on 11 May 2012
1 answer
169 views
I want to display a tooltip for data points on the selectionPreview area on the TimeBar when the user does a mouseover on a RadColumnSparkline within a RadTimeBar.  Is there a way to do this, as the selectionThumbPreview on the RadTimeBar is displayed in this area? 
Tsvetie
Telerik team
 answered on 11 May 2012
1 answer
104 views
Hi ,
i am new to WPF and Telerik Controls , so obvious answers are also appreciated . 
i need  to implement RadGridView as a custom resuseable control  as per client's requirements .i have created a radgridview in a wpf application with columns and their relevent bindings but client wants it as a custom control which when dragged to wpf window contains all columns by default and by just setting DataContext of the control will populate all the columns with data.
please guide me towards this implementation.
thanks               
Nick
Telerik team
 answered on 11 May 2012
3 answers
100 views
Hi,

i want to set the Startup color from white to a different one. This color i want to set by code (c#).
I tried this:

Color kdcol = ITA_CRM.Klassen.helper.HexColor("#FF008062");
// kdcol = "#FF008062"
this.KundenColorRCE.SelectedColor = kdcol;
this.KundenColorRCE.InitialColor = kdcol;

But in the form it is still white! Why?

Thanks a lot
Regards
Rene
Petar Mladenov
Telerik team
 answered on 11 May 2012
3 answers
113 views
Hi, 


I've recently started using Telerik WPF controls so bare with me when I try to explain my problem.  First thing I have tried to do was to create a dynamic layout docking application.  As shown in number of tutorials, I have created a simple WPF application with RadDocumentHost and another UI class that looks like this: 


<telerik:RadDocumentPane x:Class="RadControlsWpfApp1.RadControlsScenario1"<br>        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br>        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br><span class="Apple-tab-span" style="white-space:pre">       </span>xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"<br>        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"<br>        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"<br>        Header="RadControlsScenario1" mc:Ignorable="d" d:DesignHeight="288" d:DesignWidth="290"><br>    <Grid><br>        <TextBlock Text="Blah blah blah"/><br>    </Grid><br></telerik:RadDocumentPane>



When I try to look at the xaml for this window in VS designers, all I get is a large grey box that covers the entire area.  At that point I can't drag/drop any new controls onto the window.  


Also, in another application that I have converted to use RadDocumentPane, I get very large header tabs at runtime ( about half of the client space is covered by the header tab ).


Has anyone seen this too?  Any help would be greatly appriciated.


Btw, I'm running latest version of the WPF toolkit ( 2012.1.326.40 )
Yana
Telerik team
 answered on 11 May 2012
1 answer
113 views
Hi,

I'm evaluating Telerik Radcontrols for WPF to see how easy it is get done everything UX guys can think of. Now I have the following case in my hands:

I need to have an extending menu that has default mode of showing 30px column of icons by default. End user can click on a button to make the menu expand, showing icons and text. I suppose this can be done with expander quite easily.

The thing is that the expander needs to be placed inside a split container, and the split container needs to expand with the expander, quite as smoothly. In practice, I guess I would have to animate the split container, in sync with the expander animation. Is there an easy way to do this?

Br,

:^Panu>
Viktor Tsvetkov
Telerik team
 answered on 11 May 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?