标签位置

时间:2016-03-20 08:58:10

标签: c# wpf xaml silverlight scichart

我有scichart图。由于数字过多,Scichart标签被隐藏。 如何让它可见? 也许保留一些像素? 如何通过xaml或代码控制标签的边距?

我为图表写的xaml:

<UserControl x:Class="EZTrader.Graph.GraphView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:converters="clr-namespace:EZTrader.Converters"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:graph="clr-namespace:EZTrader.Graph"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
         xmlns:t="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
         x:Name="GraphControlEx"
         d:DataContext="{d:DesignInstance graph:GraphViewModel}"
         d:DesignHeight="300"
         d:DesignWidth="400"
         mc:Ignorable="d">
<UserControl.Resources>
    <converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
    <Style x:Key="GridLineStyle"
           TargetType="Line">
        <Setter Property="Stroke"
                Value="{StaticResource ChartGridLineBrush}" />
    </Style>
    <Style x:Key="AxisLabelStyle"
           TargetType="s:DefaultTickLabel">
        <Setter Property="Foreground"
                Value="Pink" />
    </Style>
    <ControlTemplate x:Key="LastTickTemplate"
                     TargetType="Control">
        <Border Name="PART_BoxAnnotationRoot"
                Width="10"
                Height="10"
                Margin="-5,-5,0,0">
            <Ellipse Fill="{StaticResource CurrentValueBrush}" />
        </Border>
    </ControlTemplate>

</UserControl.Resources>

<t:BusyIndicator IsBusy="{Binding IsLoadingGraph}">
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>

            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <graph:GraphHeaderView Grid.Row="0"
                               DataContext="{Binding HeaderViewModel}"
                               Visibility="{Binding ElementName=LayoutRoot,
                                                    Path=DataContext.HeaderViewModel,
                                                    Converter={StaticResource NullToVisibilityConverter}}" />

        <s:SciStockChart x:Name="Chart"
                         Grid.Row="1"
                         IsPanEnabled="True"
                         IsRubberBandZoomEnabled="False"
                         SeriesSource="{Binding SeriesViewModels}"
                         s:ThemeManager.Theme="EZ">
            <s:SciStockChart.Background>
                <ImageBrush ImageSource="../Resources/Images/ChartBackground.jpg" />
            </s:SciStockChart.Background>
            <s:SciChartSurface.RenderSurface >
                <s:HighQualityRenderSurface Rendered="Rendered_Event" />
            </s:SciChartSurface.RenderSurface>
            <s:SciStockChart.GridLinesPanelStyle>
                <Style TargetType="Control">
                    <Setter Property="BorderBrush"
                            Value="{StaticResource ChartGridLineBrush}" />
                </Style>
            </s:SciStockChart.GridLinesPanelStyle>
            <s:SciStockChart.XAxisStyle>
                <Style TargetType="s:CategoryDateTimeAxis">
                    <Setter Property="BarTimeFrame" Value="{Binding BarTimeFrame, Mode=OneWay}"/>
                    <Setter Property="VisibleRange" Value="{Binding XVisibleRange, Mode=TwoWay}"/>
                    <Setter Property="DrawMinorGridLines" Value="False" />
                    <Setter Property="DrawMajorTicks" Value="False"/>
                    <Setter Property="DrawMajorBands" Value="False"/>
                    <Setter Property="DrawMajorGridLines" Value="False"/>
                    <Setter Property="DrawLabels" Value="True"/>
                    <Setter Property="DrawMinorTicks" Value="False"/>
                    <Setter Property="GrowBy" Value="0, 0.1"/>
                </Style>
            </s:SciStockChart.XAxisStyle>

            <s:SciStockChart.YAxisStyle>

                <Style TargetType="s:NumericAxis">

                    <Setter Property="CursorTextFormatting" Value="0.000###"></Setter>
                    <Setter Property="AutoRange" Value="Always"/>
                    <Setter Property="TickTextBrush" Value="Gray"/>
                    <Setter Property="DrawMinorGridLines" Value="False" />
                    <Setter Property="DrawMajorTicks" Value="False"/>
                    <Setter Property="DrawMajorBands" Value="False"/>
                    <Setter Property="DrawMajorGridLines" Value="False"/>
                    <Setter Property="DrawLabels" Value="True"/>
                    <Setter Property="DrawMinorTicks" Value="False"/>
                    <Setter Property="TextFormatting" Value="0.#######" />
                </Style>
            </s:SciStockChart.YAxisStyle>
        </s:SciStockChart>

        <ListBox Grid.Row="1"
                 HorizontalAlignment="Left"
                 VerticalAlignment="Top"
                 Margin="20"
                 ItemsSource="{Binding ZoomOptions}"
                 SelectedItem="{Binding SelectedZoomOption, Mode=TwoWay}"
                 DisplayMemberPath="Name">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Width"
                            Value="30" />
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        <Grid Grid.Row="1" Margin="0,30,70,0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="20" Width="200">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <ComboBox Grid.Column="1"
                  ItemsSource="{Binding SeriesStyles}"
                  SelectedItem="{Binding SelectedSeriesStyle,
                                         Mode=TwoWay}" Margin="10,0,0,0" />

        </Grid>

    </Grid>
</t:BusyIndicator>

图片:

enter image description here

0 个答案:

没有答案