Click or drag to resize

TimeNSales View Template

User can change the complete look and feel of the TimeNSales View by building custom xaml template. The TimeNSales view is binded with a TimeNSalesViewModel object

Naming Convention

Any custom TimeNSales xaml template must have the suffix TimeNSales. For example if you name your TimeNSales template as MyTS, then the dataTemplate's key will be MyTSTimeNSales.

XAML
<DataTemplate x:Key="MyTSTimeNSales">
  <!-- design your template here -->
</DataTemplate>
Default template
Common namespaces
xmlns:bControls="clr-namespace:SharpCharts.Base.Controls;assembly=SharpCharts.Base"
xmlns:bCommon="clr-namespace:SharpCharts.Base.Common;assembly=SharpCharts.Base"
xmlns:bOrder="clr-namespace:SharpCharts.Base.Order;assembly=SharpCharts.Base"
xmlns:bData="clr-namespace:SharpCharts.Base.Data;assembly=SharpCharts.Base"
Default TimeNSales View template
<DataTemplate x:Key="DefaultTimeNSales">
    <Grid DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type Window}}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />

            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <TextBlock Text="{Binding SelectedInstrument.RealTimeData.Bid.PriceString}" FontSize="16" HorizontalAlignment="Center" />
        <TextBlock Grid.Row="1" Text="{Binding SelectedInstrument.RealTimeData.Bid.Volume}" HorizontalAlignment="Center"/>
        <TextBlock Grid.Column="1" Text="{Binding SelectedInstrument.RealTimeData.Ask.PriceString}" FontSize="16" HorizontalAlignment="Center"/>
        <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding SelectedInstrument.RealTimeData.Ask.Volume}" HorizontalAlignment="Center"/>

        <ListBox Grid.Row="2" Grid.ColumnSpan="2" ItemsSource="{Binding Quotes}" 
                 SelectionMode="Single" ItemContainerStyle="{StaticResource defaultTnSColorStyle}" Grid.IsSharedSizeScope="True" HorizontalContentAlignment="Stretch" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding Time, StringFormat=HH:mm:ss, Mode=OneTime}" />
                        <TextBlock Grid.Column="1" Text="{Binding PriceString, Mode=OneTime}" />
                        <TextBlock Grid.Column="2" Text="{Binding Volume, Mode=OneTime}"/>                                
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</DataTemplate>
See Also