<UserControl x:Class="TradeBlotter.Views.MGSHMomentumView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
						 xmlns:vw="clr-namespace:TradeBlotter.Views"												 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0" 
             xmlns:dc="clr-namespace:TradeBlotter.UIUtils"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
						 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
						 xmlns:local="clr-namespace:TradeBlotter.UIUtils"			
			      xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"						 
             mc:Ignorable="d" 
             d:DesignHeight="340" d:DesignWidth="768">
  <UserControl.Resources>
    <Style x:Key="MomentumItemStyle" TargetType="{x:Type telerik:RadGridView}"></Style>
      <local:DoubleValueConverter x:Key="DoubleFormat"/>
      <local:IntValueConverter x:Key="IntFormat"/>
      <local:DateValueConverter x:Key="DateFormat"/>
      <local:RMultipleValueConverter x:Key="RMultipleFormat"/>
  </UserControl.Resources>
  <wpfx:BusyIndicator Name="BusyBar" IsBusy="{Binding Path=BusyIndicator}" BusyContent="{Binding Path=BusyContent}">
    <Grid  Background="LightGray">
      <DockPanel>
        <Grid DockPanel.Dock="Left" Margin="0,2,4,2">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="3" />
            <ColumnDefinition Width="11*" />
            <ColumnDefinition Width="3" />
            <ColumnDefinition Width="11*" />
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
            <RowDefinition Height="35" />
            <RowDefinition Height="3" />
            <RowDefinition Height="1*" />
            <RowDefinition Height="3" />
            <RowDefinition Height="2*" />
          </Grid.RowDefinitions>
          <TextBox Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="5" FontFamily="Arial" BorderThickness="0"  IsReadOnly="true" Background="Transparent" Text="{Binding Path=Title, Mode=OneWay}" HorizontalAlignment="Center" FontSize="20"></TextBox>
          <StackPanel Orientation="Vertical" Grid.Row="2" Grid.RowSpan="3" Grid.Column="0" Margin="0,4.962,0.396,-5">
            
            <Label Content="Last Trade Date" HorizontalAlignment="Left" ></Label>
            <TextBox  Height="24" MinWidth="80" HorizontalAlignment="Stretch" IsReadOnly="true" Text="{Binding Path=LastTradeDate, Mode=OneWay}" />
            <Label Content="Next Trade Date" HorizontalAlignment="Left" ></Label>
            <TextBox  Height="24" MinWidth="80" HorizontalAlignment="Stretch" IsReadOnly="true" Text="{Binding Path=NextTradeDate, Mode=OneWay}" />

            <!--<telerik:RadDatePicker SelectableDateStart="{Binding Path=SelectableDateStart}" SelectableDateEnd="{Binding Path=SelectableDateEnd}" VerticalAlignment="Top"  HorizontalAlignment="Left" SelectedDate="{Binding Path=SelectedDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>-->
            
            <Label Content="Parameters" HorizontalAlignment="Left" ></Label>
            <ComboBox ItemsSource="{Binding Path=Parameters, Mode=OneWay}" SelectedItem="{Binding Path=SelectedParameter, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{x:Null}" >
              <ComboBox.ItemsPanel>
                <ItemsPanelTemplate>
                  <VirtualizingStackPanel/>
                </ItemsPanelTemplate>
              </ComboBox.ItemsPanel>
            </ComboBox>
            <TextBox  Height="24" MinWidth="80" HorizontalAlignment="Stretch" IsReadOnly="true" Text="{Binding Path=ParameterValue, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}"/>
            
            <Label Content="Tradeable Cash" HorizontalAlignment="Left" ></Label>
            <TextBox  Height="24" MinWidth="80" HorizontalAlignment="Stretch" IsReadOnly="true" Text="{Binding Path=CashBalance, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}"/>
            
						<Label Content="Non-Tradeable Cash" HorizontalAlignment="Left" ></Label>
						<TextBox  Height="24" MinWidth="80" HorizontalAlignment="Stretch" IsReadOnly="true" Text="{Binding Path=NonTradeableCash, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}"/>

            <Label Content="Hedge Cash" HorizontalAlignment="Left" ></Label>
            <TextBox  Height="24" MinWidth="80" HorizontalAlignment="Stretch" IsReadOnly="true" Text="{Binding Path=HedgeCash, Mode=OneWay,ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}" Validation.ErrorTemplate="{x:Null}"/>



            <Button Margin="0,2" Content="Find Candidates" HorizontalAlignment="Stretch" Command="{Binding Path=RunCommand}"></Button>
            <Label Content="Monitor Interval (sec)" HorizontalAlignment="Left" ></Label>
            <ComboBox ItemsSource="{Binding Path=MonitorIntervals, Mode=OneWay}" SelectedItem="{Binding Path=SelectedMonitorInterval, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{x:Null}" >
              <ComboBox.ItemsPanel>
                <ItemsPanelTemplate>
                  <VirtualizingStackPanel/>
                </ItemsPanelTemplate>
              </ComboBox.ItemsPanel>
            </ComboBox>
            <Button Margin="0,2" IsEnabled="{Binding Path=CanMonitor}" Content="{Binding Path=MonitorStatus}" HorizontalAlignment="Stretch" Command="{Binding Path=Monitor}"></Button>
            <Button Content="Load Trade File" HorizontalAlignment="Stretch" Command="{Binding Path=LoadFile}"></Button>
            <Button Content="Reload" HorizontalAlignment="Stretch" Command="{Binding Path=Reload}" IsEnabled="{Binding Path=ReloadEnabled}"></Button>
            <Button Margin="0,2" Content="{Binding Path=PercentButtonText}" HorizontalAlignment="Left" Command="{Binding Path=ToggleReturnOrPercentCommand}"></Button>
            <Label Content="Expectancy" HorizontalAlignment="Left" ></Label>
            <TextBox Background="WhiteSmoke" Focusable="false" Height="24" MinWidth="80" HorizontalAlignment="Stretch" IsReadOnly="true" Text="{Binding Path=ModelExpectation, Mode=OneWay}" Foreground="{Binding Path=ExpectationColor}" >
              <ToolTipService.ToolTip>
                <ToolTip IsEnabled="true" HasDropShadow="True">
                  <TextBlock Background="LemonChiffon" Text="{Binding Path=ExpectationDescription}"/>
                </ToolTip>
              </ToolTipService.ToolTip>
            </TextBox>
          </StackPanel>

          <DockPanel x:Name="DockPanelA" Grid.Row="2" Grid.Column="2" Width="Auto" Height="Auto" >
            
            <telerik:RadGridView SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}" ItemContainerStyle="{StaticResource MomentumItemStyle}" AlternationCount="2" AlternateRowBackground="Bisque" ShowGroupFooters="True" ShowColumnFooters="True" ItemsSource="{Binding Path=AllItems, ValidatesOnDataErrors=True}" AutoGenerateColumns="False" >
              <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu x:Name="GridContextMenu" StaysOpen="False" ItemsSource="{Binding CandidateMenuItems}">
                  <telerik:RadContextMenu.ItemContainerStyle>
                    <Style TargetType="telerik:RadMenuItem">
                      <Setter Property="Header" Value="{Binding Text}" />
                      <Setter Property="Command" Value="{Binding MenuItemClickedCommand}" />
                      <Setter Property="StaysOpenOnClick" Value="False" />
                    </Style>
                  </telerik:RadContextMenu.ItemContainerStyle>
                </telerik:RadContextMenu>
              </telerik:RadContextMenu.ContextMenu>
              <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn IsReadOnly="True" Header="Symbol" DataMemberBinding="{Binding Path=Symbol}" >
                  <telerik:GridViewColumn.ToolTipTemplate>
                    <DataTemplate >
                      <StackPanel Orientation="Horizontal" >
                        <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.CompanyDescription}"/>
                      </StackPanel>
                    </DataTemplate>
                  </telerik:GridViewColumn.ToolTipTemplate>
                </telerik:GridViewDataColumn>
                
                <telerik:GridViewDataColumn IsReadOnly="True" Header="AnalysisDate" DataMemberBinding="{Binding Path=AnalysisDate,StringFormat='{}{0:MM/dd/yyyy}'}" />
                
                <telerik:GridViewDataColumn IsReadOnly="True" Header="CumReturn252" DataMemberBinding="{Binding Path=CumReturn252,StringFormat='{}{0:P2}'}" />
                
                <telerik:GridViewDataColumn IsReadOnly="True" Header="DayCount" DataMemberBinding="{Binding Path=DayCount,StringFormat='{}{0:N0}'}" />
                
                <telerik:GridViewDataColumn IsReadOnly="True" Header="IDIndicator" DataMemberBinding="{Binding Path=IDIndicator,StringFormat='{}{0:N2}'}" />
                
                <telerik:GridViewDataColumn IsReadOnly="True" Header="Score" DataMemberBinding="{Binding Path=Score,Converter={StaticResource DoubleFormat},ConverterParameter=2}" />
                
                <telerik:GridViewDataColumn IsReadOnly="True" Header="PE" DataMemberBinding="{Binding Path=PE,StringFormat='{}{0:N2}'}" />

                <telerik:GridViewDataColumn IsReadOnly="True" Header="Beta" DataMemberBinding="{Binding Path=Beta,StringFormat='{}{0:N2}'}" >
                  <telerik:GridViewColumn.ToolTipTemplate>
                    <DataTemplate >
                      <StackPanel Orientation="Horizontal" >
                        <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.BetaDescription}"/>
                      </StackPanel>
                    </DataTemplate>
                  </telerik:GridViewColumn.ToolTipTemplate>
                </telerik:GridViewDataColumn>

                <telerik:GridViewDataColumn IsReadOnly="True" Header="Velocity" DataMemberBinding="{Binding Path=Velocity,StringFormat='{}{0:P2}'}" >
                  <telerik:GridViewColumn.ToolTipTemplate>
                    <DataTemplate >
                      <StackPanel Orientation="Horizontal" >
                        <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.VelocityDescription}"/>
                      </StackPanel>
                    </DataTemplate>
                  </telerik:GridViewColumn.ToolTipTemplate>
                </telerik:GridViewDataColumn>

                <telerik:GridViewDataColumn IsReadOnly="True" Header="Return1D" DataMemberBinding="{Binding Path=Return1D,StringFormat='{}{0:N3}'}" />
              </telerik:RadGridView.Columns>
            </telerik:RadGridView>
          </DockPanel>

          <DockPanel x:Name="DockPanelB" Grid.Row="2" Grid.Column="4" Width="Auto" Height="Auto" >
            <Border Grid.Row="0" Grid.Column="2" CornerRadius="6" BorderBrush="WhiteSmoke" Background="LightGray" BorderThickness="2" Padding="8"  Width="Auto" Height="Auto">
              <d3:ChartPlotter  Width="Auto" Height="Auto" Background="WhiteSmoke" Name="gainLoss" Margin="10,10,20,10" dc:ChartPlotterLegendBehavior.LegendVisibleProperty="{Binding Path=LegendVisible}" LegendVisibility="Hidden" d3:Viewport2D.UsesApproximateContentBoundsComparison="False" BorderThickness="0">
                <d3:ChartPlotter.MainHorizontalAxis>
                  <d3:HorizontalDateTimeAxis Name="dateAxis"/>
                </d3:ChartPlotter.MainHorizontalAxis>
                <d3:ChartPlotter.MainVerticalAxis>
                  <d3:VerticalAxis Name="countAxis"/>
                </d3:ChartPlotter.MainVerticalAxis>
                <d3:LineGraph d3:NewLegend.Description="Gain/Loss" d3:Viewport2D.UsesApproximateContentBoundsComparison="False" x:Name="Data" DataSource="{Binding Path=Data}" Stroke="MidnightBlue" StrokeThickness="2"/>
                <d3:CursorCoordinateGraph Name="cursorGraph" dc:CoordinateGraphBehavior.XTextMappingProperty="MM/dd/yyyy" LineStrokeThickness="1"/>
                <d3:Header FontFamily="Arial" Content="{Binding Path=GraphTitle}"/>
                <d3:VerticalAxisTitle FontFamily="Arial" Content="Gain/Loss"/>
                <d3:HorizontalAxisTitle FontFamily="Arial" Content="Date" />
              </d3:ChartPlotter>
            </Border>
          </DockPanel>


          <DockPanel x:Name="DockPanel2" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="3" Width="Auto" Height="Auto">
            <Grid>
              <Grid x:Name="PositionsView" Visibility="Visible">
                <telerik:RadGridView SelectedItem="{Binding Path=SelectedPosition, Mode=TwoWay}" ItemContainerStyle="{StaticResource MomentumItemStyle}" AlternationCount="2" AlternateRowBackground="Bisque" ShowGroupFooters="True" ShowColumnFooters="True" ItemsSource="{Binding Path=AllPositions, ValidatesOnDataErrors=True}" AutoGenerateColumns="False" >
                  <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu x:Name="PositionGridContextMenu" StaysOpen="False" ItemsSource="{Binding PositionsMenuItems}">
                      <telerik:RadContextMenu.ItemContainerStyle>
                        <Style TargetType="telerik:RadMenuItem">
                          <Setter Property="Header" Value="{Binding Text}" />
                          <Setter Property="Command" Value="{Binding MenuItemClickedCommand}" />
                          <Setter Property="StaysOpenOnClick" Value="False" />
                        </Style>
                      </telerik:RadContextMenu.ItemContainerStyle>
                    </telerik:RadContextMenu>
                  </telerik:RadContextMenu.ContextMenu>

                  <telerik:RadGridView.Columns>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Symbol" DataMemberBinding="{Binding Path=Symbol}" >
                      <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.CompanyDescriptionSelectedPosition}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Slot" DataMemberBinding="{Binding Path=SlotAsString}" />

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Purchased" DataMemberBinding="{Binding Path=PurchaseDate,StringFormat='{}{0:MM/dd/yyyy}'}" >
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=PurchaseDate,StringFormat='{}{0:MM/dd/yyyy}'}" Foreground="{Binding Path=PurchaseDateColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Sold" DataMemberBinding="{Binding Path=SellDate,StringFormat='{}{0:MM/dd/yyyy}'}" >
                      <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.ToolTipSold}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=SellDate,StringFormat='{}{0:MM/dd/yyyy}'}" Foreground="{Binding Path=SellDateColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Days" DataMemberBinding="{Binding Path=DaysHeld}" />

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Shares" DataMemberBinding="{Binding Path=Shares,StringFormat='{}{0:N0}'}" >
                      <telerik:GridViewDataColumn.AggregateFunctions>
                        <local:MGSHMomentumPositionSumFunctionShares />
                      </telerik:GridViewDataColumn.AggregateFunctions>
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Purch.Price" DataMemberBinding="{Binding Path=PurchasePrice,StringFormat='{}{0:C3}'}" />

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="CurrentPrice" >
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=CurrentPrice,StringFormat='{}{0:C3}'}" Foreground="{Binding Path=CurrentPriceColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="RSI3" >
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock >
                            <TextBlock.Style>
                              <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="Text" Value="{Binding Path=RSI3,StringFormat='{}{0:N2}'}"/>
                                <Setter Property="Foreground" Value="{Binding Path=RSI3Color}"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=RSI3}" Value="NaN" >
                                    <Setter Property="Text" Value="---"/>
                                  </DataTrigger>
                                </Style.Triggers>
                              </Style>
                            </TextBlock.Style>
                          </TextBlock>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Updated" DataMemberBinding="{Binding Path=LastUpdated,StringFormat='{}{0:MM/dd/yyyy HH:mm:ss}'}" />

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Exposure">
                      <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.ToolTipExposure}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                      <telerik:GridViewDataColumn.AggregateFunctions>
                        <local:MGSHMomentumPositionSumFunctionExposure />
                      </telerik:GridViewDataColumn.AggregateFunctions>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=ActiveExposure,StringFormat='{}{0:C}'}" Foreground="{Binding Path=ActiveExposureColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Market Value">
                      <telerik:GridViewDataColumn.AggregateFunctions>
                        <local:MGSHMomentumPositionSumFunctionMarketValue />
                      </telerik:GridViewDataColumn.AggregateFunctions>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=ActiveMarketValue,StringFormat='{}{0:C}'}" Foreground="{Binding Path=ActiveMarketValueColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="GainLoss"  >
                      <telerik:GridViewDataColumn.AggregateFunctions>
                        <local:MGSHMomentumPositionSumFunctionGainLoss />
                      </telerik:GridViewDataColumn.AggregateFunctions>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=GainLoss,StringFormat='{}{0:C}'}" Foreground="{Binding Path=GainLossColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="GainLoss(%)" >
                      <telerik:GridViewDataColumn.AggregateFunctions>
                        <local:MGSHMomentumPositionSumFunctionGainLossPcnt />
                      </telerik:GridViewDataColumn.AggregateFunctions>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=GainLossPcnt,StringFormat='{}{0:P3}'}" Foreground="{Binding Path=GainLossPcntColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Initial Stop" DataMemberBinding="{Binding Path=InitialStopLimit,StringFormat='{}{0:C}'}" >
                      <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.ToolTipInitialStop}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=InitialStopLimit,StringFormat='{}{0:C}'}" Foreground="{Binding Path=InitialStopLimitColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Trailing Stop" DataMemberBinding="{Binding Path=TrailingStopLimit,StringFormat='{}{0:C}'}" >
                      <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.ToolTipTrailingStop}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=TrailingStopLimit,StringFormat='{}{0:C}'}" Foreground="{Binding Path=TrailingStopLimitColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="R/Share" DataMemberBinding="{Binding Path=R,StringFormat='{}{0:C}'}" >
                      <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.ToolTipR}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=R,StringFormat='{}{0:C}'}" Foreground="{Binding Path=RColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Risk" DataMemberBinding="{Binding Path=TotalRiskExposure,StringFormat='{}{0:C}'}" >
                      <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.ToolTipTotalRiskExposure}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                      <telerik:GridViewDataColumn.AggregateFunctions>
                        <local:MGSHPositionSumFunctionRisk />
                      </telerik:GridViewDataColumn.AggregateFunctions>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=TotalRiskExposure,StringFormat='{}{0:C}'}" Foreground="{Binding Path=TotalRiskExposureColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="RMultiple" DataMemberBinding="{Binding Path=RMultiple,Converter={StaticResource RMultipleFormat}}" >
                        <telerik:GridViewColumn.ToolTipTemplate>
                        <DataTemplate >
                          <StackPanel Orientation="Horizontal" >
                            <TextBlock Background="LemonChiffon" MaxWidth="1000" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type vw:MGSHMomentumView}},Path=DataContext.ToolTipRMultiple}"/>
                          </StackPanel>
                        </DataTemplate>
                      </telerik:GridViewColumn.ToolTipTemplate>
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=RMultipleAsString,StringFormat='{}{0:S}'}" Foreground="{Binding Path=RMultipleColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Last Stop Adj." DataMemberBinding="{Binding Path=LastStopAdjustment,Converter={StaticResource DateFormat}}" >
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=LastStopAdjustment,Converter={StaticResource DateFormat}}" Foreground="{Binding Path=LastStopAdjustmentColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Days" DataMemberBinding="{Binding Path=DaysSinceLastStopAdjustment,Converter={StaticResource IntFormat},ConverterParameter=0}" >
                      <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding Path=DaysSinceLastStopAdjustment,Converter={StaticResource IntFormat},ConverterParameter=0}" Foreground="{Binding Path=DaysSinceLastStopAdjustmentColor}"/>
                        </DataTemplate>
                      </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn IsReadOnly="True" Header="PE" DataMemberBinding="{Binding Path=PE,StringFormat='{}{0:N2}'}" />
                    
                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Beta" DataMemberBinding="{Binding Path=Beta,StringFormat='{}{0:N2}'}" />
                    
                    <telerik:GridViewDataColumn IsReadOnly="True" Header="IDIndicator" DataMemberBinding="{Binding Path=IDIndicator,StringFormat='{}{0:N2}'}" />
                    
                    <telerik:GridViewDataColumn IsReadOnly="True" Header="Score" DataMemberBinding="{Binding Path=Score,Converter={StaticResource DoubleFormat},ConverterParameter=2}" />

                    
                  </telerik:RadGridView.Columns>
                </telerik:RadGridView>
              </Grid>
            </Grid>
          </DockPanel>
          <GridSplitter Panel.ZIndex="1" Background="LightBlue" ResizeDirection="Rows"  Grid.Column="2" Grid.ColumnSpan="5"  Grid.Row="3" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0"/>
          <GridSplitter Grid.Row="1" Grid.Column="1" ResizeDirection="Columns" Grid.RowSpan="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="LightBlue" Width="3"/>
          <GridSplitter Grid.Row="1" Grid.Column="3" ResizeDirection="Columns" Grid.RowSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="LightBlue" Width="3"/>
        </Grid>
      </DockPanel>
    </Grid>
  </wpfx:BusyIndicator>
</UserControl>                                                                                                                                            

