我为我的 windows phone 8 开发了 UserControl,如下所示。
<UserControl x:Class="SpinrWindowsMobile.UserControls.ProgressiveLongListSelector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<phone:LongListSelector Grid.Row="0" Name="longlistselector">
</phone:LongListSelector>
<StackPanel Grid.Row="1">
<ProgressBar Name="listProress" IsIndeterminate="True"></ProgressBar>
<TextBlock Name="ProgressText" Text="Loading..."></TextBlock>
</StackPanel>
</Grid>
</UserControl>
正如您在上面的 xaml 中看到的,我在网格控件中使用了 LongListSelector 和 StackPanel 。我在我的 MainPage.xaml 中使用此控件,如下所示。
<phone:PhoneApplicationPage
x:Class="SpinrWindowsMobile.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UserControls="clr-namespace:SpinrWindowsMobile.UserControls"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<UserControls:ProgressiveLongListSelector>
</UserControls:ProgressiveLongListSelector>
</Grid>
</phone:PhoneApplicationPage>
到目前为止,这很好,但我想做如下的事情。
<UserControls:ProgressiveLongListSelector>
<UserControls:ProgressiveLongListSelector.longlistselector
ItemsSource="Binding" ItemTemplate="{staticresource myTemplate}">
</UserControls:ProgressiveLongListSelector.longlistselector>
</UserControls:ProgressiveLongListSelector>
如何访问作为UserControl的元素/组件的longlistselector ?这样做的好处是。对我来说,这种东西是今天的要求。I can directly set the LongListSelector Properties in the xaml(in which i am embedding My usercontrol) itself
谁能指导我如何做到这一点?