I have a Windows Phone application which gets data from a SQL server with WCF.
The data gets into a ListBox and there is a column with the name Status.
The column status, need to show images instead of numbers, right know i shows 0 for succes, 1 for warning, 2 alarm.
Can anyone point me in the right direction?
Thanks.
MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using NSSPhoneApp.NSSServiceReference;
using System.ServiceModel;
namespace NSSPhoneApp
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
NSSServiceClient client = new NSSServiceClient();
client.GetAllServer_LogsCompleted +=
new EventHandler<GetAllServer_LogsCompletedEventArgs>(client_GetAllServer_LogsCompleted);
client.GetAllServer_LogsAsync();
}
void client_GetAllServer_LogsCompleted(object sender, GetAllServer_LogsCompletedEventArgs e)
{
if (e.Error == null)
{
lst.ItemsSource = e.Result;
}
}
}
}
MainPage.xaml only ContentPanel
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox Height="Auto" HorizontalAlignment="Stretch" Margin="0,0,0,6" Name="lst" VerticalAlignment="Stretch" Width="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Status}" Margin="12,0,12,0"/>
<TextBlock Text="{Binding Name}" Margin="12,0,12,0"/>
<TextBlock Text="{Binding IP}" Margin="12,0,12,0"/>
<TextBlock Text="{Binding Task}" Margin="12,0,12,0"/>
<TextBlock Text="{Binding Message}" Margin="12,0,12,0"/>
<TextBlock Text="{Binding Time}" Margin="12,0,12,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
Untested you will have to figure out how to show the image properly.