回复 6楼不停息的翔龙的帖子
可以自己写Convert,把标题放到中间。
Xmalcode参考:
- <Grid>
- <Grid.Resources>
- <Data:TitileAlignmentConvert x:Key="widthConverter"/>
- </Grid.Resources>
- <DockPanel>
-
- <c1:C1Chart HorizontalAlignment="Stretch" Name="c1Chart1" VerticalAlignment="Stretch">
- <c1:C1Chart.Data>
- <c1:ChartData ItemNames="P1 P2 P3 P4 P5">
- <c1:DataSeries Label="Series 1" RenderMode="Default" Values="20 22 19 24 25" />
- <c1:DataSeries Label="Series 2" RenderMode="Default" Values="8 12 10 12 15" />
- </c1:ChartData>
- </c1:C1Chart.Data>
- <TextBlock DockPanel.Dock="Top" Text="2013年度报表" HorizontalAlignment="Center">
- <TextBlock.RenderTransform>
- <TranslateTransform X="{Binding Path=ActualWidth,ElementName=c1Chart1,Converter={StaticResource widthConverter}}"/>
- </TextBlock.RenderTransform>
- </TextBlock>
- <c1:C1ChartLegend />
- </c1:C1Chart>
- </DockPanel>
- </Grid>
复制代码
Converter代码:
- [ValueConversion(typeof(double), typeof(double))]
- public class TitileAlignmentConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- double width = 0;
- if (double.TryParse(value.ToString(), out width))
- {
- width = width / 2;
- }
- return width;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value;
- }
- }
复制代码 |