The sample TraceViewer from IdeaBlade is in the folder:
C:\Program Files\IdeaBlade DevForce\Learning Resources\110_Deployment\Snippets\Silverlight\TraceWindow
Here is another version of that control that appears as a popup panel within your page. The Popup control has no TitleBar and can't be easily moved, but it does sit on top of other controls, so, for better or worse, here it is:
XAML:
<UserControl x:Class="Silverlight.Controls.IdeabladeTraceViewer.TraceViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:controls="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls"
Width="Auto" Height="Auto"
>
<Popup x:Name="TraceViewerPopup"
Canvas.Left="550"
Canvas.Top="500"
>
<Grid x:Name="LayoutRoot" Margin="20,20,20,20" >
<data:DataGrid
x:Name="_dataGrid"
HorizontalAlignment="Left"
VerticalAlignment="Top"
AutoGenerateColumns="True"
MinWidth="250"
MinHeight="100"
MaxWidth="600"
MaxHeight="200"
Background="#FFB5BAB5"
Margin="0,0,20,0"
IsReadOnly="True"
/>
</Grid>
</Popup>
</UserControl>
Code behind:
using System;
using System.Collections.ObjectModel;
using System.Windows.Controls;
using IdeaBlade.Core;
namespace Silverlight.Controls.IdeabladeTraceViewer
{
public partial class TraceViewer : UserControl
{
public TraceViewer()
{
InitializeComponent();
TraceViewerPopup.IsOpen = true;
_messages = new ObservableCollection<TraceMessage>();
_subscriber = new TraceSubscriber();
_subscriber.Publish += new EventHandler<PublishEventArgs>(_subscriber_Publish);
_subscriber.StartSubscription();
_dataGrid.ItemsSource = _messages;
}
private void _subscriber_Publish(object sender, PublishEventArgs e)
{
_messages.Add(e.TraceMessage);
if (_dataGrid.Columns.Count > 0)
{
_dataGrid.ScrollIntoView(e.TraceMessage, _dataGrid.Columns[0]);
}
}
TraceSubscriber _subscriber;
ObservableCollection<TraceMessage> _messages;
}
}
And, last but not least, in the View's Constructor to instantiate the popup trace viewer:
InitializeComponent();
var traceViewer = new Silverlight.Controls.IdeabladeTraceViewer.TraceViewer();
}
If anyone has a simple way to float the viewer so it can be moved around, please post a sample. Thanks!
|