wp7 -加载更多信息
public partial class RefreshMore : UserControl
{
model mymodel = new model() { SEX = true };
private ObservableCollection<EmailObject> DemoData = new ObservableCollection<EmailObject>();
public RefreshMore()
{
InitializeComponent();
this.listBox1.ItemsSource = this.DemoData;
this.DataContext = mymodel;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
string buf = "Good night ! ";
for (int i = 0; i < 10; i++)
{
DemoData.Add(new EmailObject() { Body = buf + i ,Read="",Unread=false});
}
}
private void Buton_Click(object sender, RoutedEventArgs e)
{
string buf = "Good night ! ";
for (int i = 0; i < 15; i++)
{
DemoData.Add(new EmailObject() { Body = buf + i, Read = "", Unread = false });
}
mymodel.SEX = false;
}
}
uc
<Converters:BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
<Grid x:Name="LayoutRoot">
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="30" Margin="0,-30,-3,0" Width="400" Visibility="Visible"/>
<ListBox Grid.Row="1" x:Name="listBox1" Margin="15,0" SelectionMode="Multiple" ItemsSource="{Binding LstModel}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,20">
<Rectangle Height="100" Width="100" Fill="#FFE5001b" Margin="0,0,9,0"/>
<TextBlock Text="{Binding Body}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Grid.Row="2" x:Name="Buton" Height="72" Content="加载更多" Visibility="{Binding SEX, Converter={StaticResource BoolToVisConverter}}" Click="Buton_Click"/>
</Grid>
</ScrollViewer>
</Grid>
在你的父控件上面 <my:RefreshMore x:Name="MyRefreshMore"/>
大概思路是这样的。。牛人勿喷我啊。我还是初学者