【发布时间】:2015-09-02 07:08:57
【问题描述】:
我如何在列表框中的 windows phone 中的 textblock 中绑定 observable 集合计数值
<Grid Margin="440,26,10,0" Grid.Row="1" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,0,0">
<Grid Height="25" MinWidth="25">
<Grid.Background>
<ImageBrush ImageSource="{Binding Image}" Stretch="Fill"/>
</Grid.Background>
<TextBlock Name="Message_Count" Text="{Binding CollectionCount}" Foreground="White" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
</Grid>
List<CountMsg> retrieved = dbConnCount.Table<CountMsg>().ToList<CountMsg>();
dbCount = new ObservableCollection<CountMsg>(retrieved);
我想在文本块中绑定 dbCount.Count;
【问题讨论】:
-
定义一个只读属性,它是
getter,返回dbCount.Count,然后将你的textBlock.Text绑定到这个属性。 -
Bahman_Aries 先生,您能否发送更多信息或任何紧急情况的示例
标签: c# wpf xaml windows-phone-8