如何在代码后面访问listviews面板?
Xaml定义:
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<telerik:RadCarouselPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
如果我命名面板,在代码隐藏中引用它时会出现编译时错误。
答案 0 :(得分:1)
一种方法是在加载时存储RadCarouselPanel
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<telerik:RadCarouselPanel Loaded="RadCarouselPanel_Loaded"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
并在代码中
private RadCarouselPanel m_radCarouselPanel = null;
private void RadCarouselPanel_Loaded(object sender, RoutedEventArgs e)
{
m_radCarouselPanel = sender as RadCarouselPanel;
}