gpt4 book ai didi

C# 图表适合一个选项卡

转载 作者:行者123 更新时间:2023-11-30 12:50:47 26 4
gpt4 key购买 nike

我有制作制表符的 C# 代码。我必须将 4 个制表符合并为 1 个。在左下角您可以看到:

Screenshot

为此编写的代码:我认为问题出在网格行和网格列上,正如您所看到的那样存在重叠并且第 4rth 个选项卡根本没有显示。

        <Button x:Class="TDashboard.Common.Modules.CNASummary.Views.CNASummaryTileView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:vc="clr-namespace:Visifire.Charts;assembly=WPFVisifire.Charts"
mc:Ignorable="d"
d:DesignHeight="280"
d:DesignWidth="560"
MinHeight="{StaticResource TileMinHeight}"
MinWidth="{StaticResource TileMinWidth}"
MaxHeight="{StaticResource TileMaxHeight}"
MaxWidth="{StaticResource TileMaxWidth}"
Command="{Binding Command}"
Template="{StaticResource TileControlTemplate}">
<StackPanel Orientation="Vertical"
dx:ThemeManager.ThemeName="Office2007Blue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="120" />
<RowDefinition Height="120" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="260" />
<ColumnDefinition Width="260" />
</Grid.ColumnDefinitions>

<vc:Chart x:Name="CNAPoorEating"
Watermark="False"
Width="Auto"
Height="Auto"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
MinHeight="60"
MinWidth="{StaticResource ChartMinWidth}"
CornerRadius="11,11,11,11"
RenderTransformOrigin="0.5,0.5"
FontSize="8"
Background="Transparent" Grid.Column="0" Grid.Row="0">
<vc:Chart.PlotArea>
<vc:PlotArea Background="#00000000" />
</vc:Chart.PlotArea>
<vc:Chart.Titles>
<vc:Title Text="Num. Patients Poor Eating" />
</vc:Chart.Titles>
<vc:Chart.AxesX>
<vc:Axis IntervalType="Days"
ValueFormatString="MMM-d"
Interval="1">
<vc:Axis.AxisLabels>
<vc:AxisLabels Angle="0" />
</vc:Axis.AxisLabels>
</vc:Axis>
</vc:Chart.AxesX>
<vc:Chart.Series>
<vc:DataSeries RenderAs="Column"
DataSource="{Binding CNAPoorEatingData}"
XValueFormatString="MMM-d">
<vc:DataSeries.DataMappings>
<vc:DataMapping MemberName="XValue"
Path="Day" />
<vc:DataMapping MemberName="YValue"
Path="Count" />
</vc:DataSeries.DataMappings>
</vc:DataSeries>
</vc:Chart.Series>
</vc:Chart>

<vc:Chart x:Name="CNABathing"
Watermark="False"
Width="Auto"
Height="Auto"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
MinHeight="60"
MinWidth="{StaticResource ChartMinWidth}"
CornerRadius="11,11,11,11"
RenderTransformOrigin="0.5,0.5"
FontSize="8"
Background="Transparent" Grid.Column="1" Grid.Row="0">
<vc:Chart.PlotArea>
<vc:PlotArea Background="#00000000" />
</vc:Chart.PlotArea>
<vc:Chart.Titles>
<vc:Title Text="CNABathing" />
</vc:Chart.Titles>
<vc:Chart.AxesX>
<vc:Axis IntervalType="Days"
ValueFormatString="MMM-d"
Interval="1">
<vc:Axis.AxisLabels>
<vc:AxisLabels Angle="0" />
</vc:Axis.AxisLabels>
</vc:Axis>
</vc:Chart.AxesX>
<vc:Chart.Series>


<vc:DataSeries RenderAs="Column"
DataSource="{Binding CNABathingData}"
XValueFormatString="MMM-d">
<vc:DataSeries.DataMappings>
<vc:DataMapping MemberName="XValue"
Path="Day" />
<vc:DataMapping MemberName="YValue"
Path="Count" />
</vc:DataSeries.DataMappings>
</vc:DataSeries>
</vc:Chart.Series>
</vc:Chart>

<vc:Chart x:Name="CNABowel"
Watermark="False"
Width="Auto"
Height="Auto"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
MinHeight="60"
MinWidth="{StaticResource ChartMinWidth}"
CornerRadius="11,11,11,11"
RenderTransformOrigin="0.5,0.5"
FontSize="8"
Background="Transparent" Grid.Column="2" Grid.Row="0">
<vc:Chart.PlotArea>
<vc:PlotArea Background="#00000000" />
</vc:Chart.PlotArea>
<vc:Chart.Titles>
<vc:Title Text="CNABowel" />
</vc:Chart.Titles>
<vc:Chart.AxesX>
<vc:Axis IntervalType="Days"
ValueFormatString="MMM-d"
Interval="1">
<vc:Axis.AxisLabels>
<vc:AxisLabels Angle="0" />
</vc:Axis.AxisLabels>
</vc:Axis>
</vc:Chart.AxesX>
<vc:Chart.Series>
<vc:DataSeries RenderAs="Column"
DataSource="{Binding CNASource}"
XValueFormatString="MMM-d">
<vc:DataSeries.DataMappings>
<vc:DataMapping MemberName="XValue"
Path="Day" />
<vc:DataMapping MemberName="YValue"
Path="Count" />
</vc:DataSeries.DataMappings>
</vc:DataSeries>
</vc:Chart.Series>
</vc:Chart>

<vc:Chart x:Name="CNAIntakeVsOutput"
Watermark="False"
Width="Auto"
Height="Auto"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
MinHeight="60"
MinWidth="{StaticResource ChartMinWidth}"
CornerRadius="11,11,11,11"
RenderTransformOrigin="0.5,0.5"
FontSize="8"
Background="Transparent" Grid.Column="2" Grid.Row="2">
<vc:Chart.PlotArea>
<vc:PlotArea Background="#00000000" />
</vc:Chart.PlotArea>
<vc:Chart.Titles>
<vc:Title Text="CNAIntakeVsOutput" />
</vc:Chart.Titles>
<vc:Chart.AxesX>
<vc:Axis IntervalType="Days"
ValueFormatString="MMM-d"
Interval="1">
<vc:Axis.AxisLabels>
<vc:AxisLabels Angle="0" />
</vc:Axis.AxisLabels>
</vc:Axis>
</vc:Chart.AxesX>
<vc:Chart.Series>
<vc:DataSeries RenderAs="Column"
DataSource="{Binding Data}"
XValueFormatString="MMM-d">
<vc:DataSeries.DataMappings>
<vc:DataMapping MemberName="XValue"
Path="Day" />
<vc:DataMapping MemberName="YValue"
Path="Count" />
</vc:DataSeries.DataMappings>
</vc:DataSeries>
</vc:Chart.Series>
</vc:Chart>



</Grid>

</StackPanel>
</Button>

最佳答案

网格行和列索引从 0 开始。由于您的网格是 2x2,可用的最高列/行索引是 1,但您在 CNAIntakeVsOutputCNABowel< 上将其设置为 2/

由于指定的行/列不存在,默认位置为 0,这意味着您有两个对象彼此重叠(仔细查看第一行的第二列)

CNAIntakeVsOutput 上的 Grid.Row 和 Grid.Column 以及 CNABowel 上的 Grid.Column 更改为 1,它应该可以正确呈现。

编辑

我还建议在您的网格中使用 * 大小的列,而不是绝对的列,这样无论屏幕大小如何,它们都会显示整个对象。

<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

这将使您的网格具有两个大小相同的列和两个大小相同的行。

关于C# 图表适合一个选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8422009/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com