我在 JSON 中获取数据并存储在 List by
List<Product> rootObject = JsonConvert.DeserializeObject<List<Product>>(e.Result);
之后,我在 ListBox 中显示数据
productlist.ItemsSource = rootObject;
我的 xaml 文件:-
<ListBox Height="600" HorizontalAlignment="Left" Margin="5,91,0,0" Name="productlist" VerticalAlignment="Top" Width="441"
SelectionChanged="productlistselectionchanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="132">
<!-- <Image Source="{Binding Path=http://callme4.com/images/classifieds/ad_images/IMG_20130728_132750.jpg}" Height="73" Width="73" VerticalAlignment="Top" Margin="0,10,8,0"/> -->
<StackPanel Width="370">
<TextBlock Text="{Binding title}" Foreground="#FFC8AB14" FontSize="28" />
<TextBlock Text="{Binding city}" TextWrapping="Wrap" FontSize="24" />
<TextBlock Name="price" Text="{Binding price}" TextWrapping="Wrap" FontSize="24" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我的列表框工作正常。
但是现在我在价格文本块中有一个条件,例如:-
if(price > 2000)
textblock values should be purchased.
else
textblock values should be "not purchased"
但我对此感到困惑,我该怎么办?
请专家检查