This is a migrated thread and some comments may be shown as answers.

TreeView, ContainerBindingCollection and IsSelectionActive

5 Answers 138 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Espen
Top achievements
Rank 1
Espen asked on 13 Oct 2010, 12:09 PM
I've currently made use of the IsExpanded property in the ContainerBindingCollection with mode TwoWay, and this works fine. When I add IsSelectionActive this also works, but only if the initial value on object I've bound to is false. If I try to set the initial value to true, everything crashes...and there's no real exception where I can see what actually goes wrong. Intended or not? IsSelectionActive has a public setter, so should work just as fine is IsExpanded shouldn't it?

Edit: I'm using the latest Q2 of the RadControls for Silverlight.

5 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 14 Oct 2010, 02:02 PM
Hello Espen,

In fact, RadTreeViewItem's IsSelectionActive property has a public getter and internal setter.



Greetings,
Kiril Stanoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Espen
Top achievements
Rank 1
answered on 14 Oct 2010, 02:12 PM
You need to fix your documentation then :)

"Gets or sets whether the tree item selection is active - e.g. the item is selected and the treeview is focused.  

 C#  
public  IsSelectionActive {get; set;}
"

That being said...the real underlying issue here is that when I open a view with a treeview (via composite framework and such), I have trouble giving the first RadTreeViewItem focus. It is selected through the IsSelected property, but it has no focus. item.Focus() doesn't seem to help either. I actually have to click inside the treeview to make the treeviewitem getting focus. I'm not sure if this is related to the RadTreeView at all actually. Maybe you know that though, or how I can get the item to get focus.
0
Kiril Stanoev
Telerik team
answered on 19 Oct 2010, 09:00 AM
Hi Espen,

The documentation will be updated as soon as possible. I've logged this issue in our public issue tracking system under the name "Remove "set" from IsSelectionActive documentation" and it will be available for tracking tomorrow the latest. I've also updated your Telerik points accordingly.

As for the other issue...it is strange that item.Focus() does not work. For example, I created an application with the code bellow and it worked as expected.

<Grid x:Name="LayoutRoot" Background="White">
    <StackPanel>
        <ScrollViewer>
            <telerik:RadTreeView>
                <!--Simpsons Family-->
                <telerik:RadTreeViewItem Header="Simpsons" IsExpanded="True">
                    <telerik:RadTreeViewItem x:Name="homer" Header="Homer" />
                    <telerik:RadTreeViewItem Header="Marge" />
                    <telerik:RadTreeViewItem Header="Bart" />
                    <telerik:RadTreeViewItem Header="Lisa" />
                    <telerik:RadTreeViewItem Header="Maggie" />
                </telerik:RadTreeViewItem>
                <!--Flanders Family-->
                <telerik:RadTreeViewItem Header="Flanders" IsExpanded="True">
                    <telerik:RadTreeViewItem Header="Ned" />
                    <telerik:RadTreeViewItem Header="Maude" />
                    <telerik:RadTreeViewItem Header="Todd" />
                    <telerik:RadTreeViewItem Header="Rod" />
                </telerik:RadTreeViewItem>
            </telerik:RadTreeView>
        </ScrollViewer>
        <Button Content="Focus Homer" Click="Button_Click" />
    </StackPanel>
</Grid>

private void Button_Click(object sender, RoutedEventArgs e)
{
    this.homer.Focus();
}

Try investigating who is stealing the focus from the TreeViewItem and make it unfocusable. Let me know if I can be of further assistance.

Regards,
Kiril Stanoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Espen
Top achievements
Rank 1
answered on 19 Oct 2010, 09:09 AM
I should probably have been clearer, but adding a button like you have done works fine. Problem is that I want it to have focus when the view opens, so I run it in the Loaded event (or actually after the treeviewitems has been loaded from a WCF data service)...and that's not working. I find it weird if the error is with the treeview though...it's just that I'm not doing any .Focus() anywhere else...and as such this should just work :P I will investigate further though.
0
Kiril Stanoev
Telerik team
answered on 19 Oct 2010, 10:10 AM
Hi Espen,

This might be shot in the dark, but let me suggest one more thing. When the TreeView gets its data from the service (assuming in the Completed event handler), call the focus in a Dispatcher. Something like:

// pseudo code implementation
private void WorkCompleted (sender, args) <-- this is the event handler for the completed event of the web service
{
   // populate the treeview with data
   treeView.ItemsSource = args.Result;
 
   // focus the first item in the treeview
   this.Dispatcher.BeginInvoke(() =>
   {
      (treeView.ItemContainerGenerator.ContainerFromIndex(0) as RadTreeViewItem).Focus();
   });
}


All the best,
Kiril Stanoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Espen
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Espen
Top achievements
Rank 1
Share this question
or