tags:

views:

23

answers:

1

How do I access the listviews panel in code behind?

Xaml definition:

        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <telerik:RadCarouselPanel />
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>

If I name the panel, I get a compile-time error when refering to it in the code-behind.

+1  A: 

One way to do it is to store the RadCarouselPanel when it is loaded

<ListView.ItemsPanel>
    <ItemsPanelTemplate>
        <telerik:RadCarouselPanel Loaded="RadCarouselPanel_Loaded"/>
    </ItemsPanelTemplate>
</ListView.ItemsPanel>

and in code behind

private RadCarouselPanel m_radCarouselPanel = null;

private void RadCarouselPanel_Loaded(object sender, RoutedEventArgs e)
{
    m_radCarouselPanel = sender as RadCarouselPanel;
}
Meleak