Market Watch View Template |
User can change the complete look and feel of the Market Watch View by building custom xaml template. The Market Watch View is binded with a MarketWatchViewModel object
Any custom Market Watch xaml template must have the suffix MarketWatch. For example if you name your custom Market Watch template as MyMW, then the dataTemplate's key will be MyMWMarketWatch.
<DataTemplate x:Key="MyMWMarketWatch"> <!-- design your template here --> </DataTemplate>
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"
<DataTemplate x:Key="DefaultMarketWatch"> <DataGrid DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" ItemsSource="{Binding Items}" SelectionMode="Single" CanUserAddRows="False" SelectedItem="{Binding SelectedInstrument}" SelectionUnit="FullRow" IsSynchronizedWithCurrentItem="True" HorizontalContentAlignment="Stretch" AutoGenerateColumns="False" IsReadOnly="True" ColumnWidth="*" > <DataGrid.InputBindings> <KeyBinding Key="{Binding Source={StaticResource ResourceKey={x:Static bCommon:ResourceKey.OptionsKey}}, Path=Delete.Key}" Modifiers="{Binding Source={StaticResource ResourceKey={x:Static bCommon:ResourceKey.OptionsKey}}, Path=Delete.ModifierKeys}" Command="{Binding RemoveInstrumentCommand}" /> </DataGrid.InputBindings> <DataGrid.Resources> <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource ResourceKey={x:Type DataGridColumnHeader}}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> <Style x:Key="dgCellStyle" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource ResourceKey={x:Type DataGridCell}}"> <Setter Property="TextBlock.TextAlignment" Value="Center" /> </Style> <Style x:Key="dgColorCellStyle" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource ResourceKey={x:Type DataGridCell}}"> <Setter Property="TextBlock.TextAlignment" Value="Center" /> <Style.Triggers> <DataTrigger Binding="{Binding Trend}" Value="Up"> <Setter Property="Background" Value="Green" /> <Setter Property="Foreground" Value="White" /> </DataTrigger> <DataTrigger Binding="{Binding Trend}" Value="Down"> <Setter Property="Background" Value="Red" /> <Setter Property="Foreground" Value="White" /> </DataTrigger> </Style.Triggers> </Style> </DataGrid.Resources> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding DisplayName, Mode=OneTime}" Header="{Loc LblInstruments, Converter={StaticResource locConverter}, ConverterParameter=LblInstruments}" /> <DataGridTextColumn Binding="{Binding Last.PriceString}" Header="{Loc LblLast, Converter={StaticResource locConverter}, ConverterParameter=LblLast}" CellStyle="{StaticResource ResourceKey=dgColorCellStyle}" /> <DataGridTextColumn Binding="{Binding Change.Price}" Header="{Loc LblChange, Converter={StaticResource locConverter}, ConverterParameter=LblChange}" CellStyle="{StaticResource ResourceKey=dgCellStyle}" /> <DataGridTextColumn Binding="{Binding Bid.Volume}" Header="{Loc LblBidVolume, Converter={StaticResource locConverter}, ConverterParameter=LblBidVolume}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> <DataGridTextColumn Binding="{Binding Bid.PriceString}" Header="{Loc LblBid, Converter={StaticResource locConverter}, ConverterParameter=LblBid}" CellStyle="{StaticResource ResourceKey=dgCellStyle}" /> <DataGridTextColumn Binding="{Binding Ask.PriceString}" Header="{Loc LblAsk, Converter={StaticResource locConverter}, ConverterParameter=LblAsk}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> <DataGridTextColumn Binding="{Binding Ask.Volume}" Header="{Loc LblAskVolume, Converter={StaticResource locConverter}, ConverterParameter=LblAskVolume}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> <DataGridTextColumn Binding="{Binding TotalVolume.Volume}" Header="{Loc LblTotalVolume, Converter={StaticResource locConverter}, ConverterParameter=LblTotalVolume}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> <DataGridTextColumn Binding="{Binding Open.Price}" Header="{Loc LblOpen, Converter={StaticResource locConverter}, ConverterParameter=LblOpen}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> <DataGridTextColumn Binding="{Binding High.Price}" Header="{Loc LblHigh, Converter={StaticResource locConverter}, ConverterParameter=LblHigh}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> <DataGridTextColumn Binding="{Binding Low.Price}" Header="{Loc LblLow, Converter={StaticResource locConverter}, ConverterParameter=LblLow}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> <DataGridTextColumn Binding="{Binding PreviousClose.Price}" Header="{Loc LblClose, Converter={StaticResource locConverter}, ConverterParameter=LblClose}" CellStyle="{StaticResource ResourceKey=dgCellStyle}"/> </DataGrid.Columns> </DataGrid> </DataTemplate>