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

IsExpandable Is not hiding the Expand Button

3 Answers 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 22 Jan 2013, 05:28 PM
I'm having issues with getting the IsExpandable property to be respected. Basically when my "Parent" has no children, I don't want the expand togglebutton to be shown. Below is some sample xaml that I am using. The resulting grid has the details column fully populated with the togglebuttons when there should be at least one without the button. I've stepped through my StyleSelector code and it is returning the proper style. But it doesn't appear to have any affect. What am I doing wrong?

<UserControl ...>
    <UserControl.Resources>
        <Style x:Key="NoChildrenRowStyle" TargetType="telerik:GridViewRow">
            <Setter Property="IsExpandable" Value="False"/>
        </Style>
  
        <Style x:Key="HasChildrenRowStyle" TargetType="telerik:GridViewRow">
            <Setter Property="IsExpandable" Value="True"/>
        </Style>
</UserControl.Resources>
  
 <local:RowStyleSelector x:Key="RowStyleSelector"
         NoChildrenStyle="{StaticResource NoChildrenRowStyle}"
         HasChildrenStyle="{StaticResource HasChildrenRowStyle}"/>
  
<telerik:RadGridView ItemsSource="{Binding ParentsCollectionView}"
        RowIndicatorVisibility="Collapsed"
        AutoGenerateColumns="False"
        RowStyleSelector="{StaticResource RowStyleSelector}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn />
                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn Header="Age" DatatMemberBinding="{Binding Age}"/>
            </telerik:RadGridView.Columns>
            <telerik:RadGridView.RowDetailsTemplate>
                <DataTemplate>
                    <ListBox ItemsSource="{Binding Children}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <TextBlock Text="{Binding Name}"/>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>  
                    </ListBox>
                </DataTemplate>
            </telerik:RadGridView.RowDetailsTemplate>
        </telerik:RadGridView>
</UserControl>

3 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 24 Jan 2013, 02:48 PM
Hello Josh,

I would suggest you to check our custom hierarchy demo for more info. Although it is for Silverlight, you can find the same demo in your local copy of WPF demos.


Regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Josh
Top achievements
Rank 1
answered on 24 Jan 2013, 03:21 PM
I'm sorry, but that answer is not helpful at the least. I've already seen the demo, I have a RowStyleSelector and it isn't working. The only difference I can see from your sample to mine is that I'm using a StyleSelector defined in code rather than xaml. But that shouldn't matter and if it does, then that's a huge shortcoming for you controls.

For clarity, I have a styleselector like this:

public class MyRowStyleSelector : StyleSelector
{
    public Style HasChildrenStyle { get; set; }
    public Style NoChildrenStyle { get; set; }
 
    public override Style SelectStyle(object item, System.Windows.DependencyObject container)
    {
        if (...)
        {
            return HasChildrenStyle;
        }
 
        return NoChildrenStyle;
    }
}
0
Yoan
Telerik team
answered on 24 Jan 2013, 04:02 PM
Hi Josh,

Indeed, you can try using a hierarchy child template instead of using RowDetails. Please find attached a sample project that shows you the approach.

Regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Josh
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Josh
Top achievements
Rank 1
Share this question
or