livecharts仪表盘报错System.Collections.Generic.KeyNotFoundException:“The given key ‘LiveCharts.Wpf.Angula

问题描述

之前写livecharts实现了仪表盘
但是等到项目成员合代码之后就无法运行
报错状态:
System.Collections.Generic.KeyNotFoundException:“The given key ‘LiveCharts.Wpf.AngularSection’ was not present in the dictionary.”

并且xaml的预览图是正常的

代码如下

<Grid >

                                                            <lvc:AngularGauge  Value="{Binding SOH}" FromValue="0" ToValue="100" 
                                                             LabelsStep="50" TicksStep="10" Wedge="230" TicksStrokeThickness="0.2"
                                                            TicksForeground="Black" Foreground="black"  
                                                             FontWeight="thin" FontSize="6"
                                                            SectionsInnerRadius=".8">
                                                                <lvc:AngularGauge.Sections>
                                                                    <lvc:AngularSection FromValue="{Binding SOH}" ToValue="100" Fill="white"/>
                                                                    <lvc:AngularSection FromValue="0" ToValue="{Binding SOH}" Fill="#0098FA"/>
                                                                    
                                                                </lvc:AngularGauge.Sections>
                                                            </lvc:AngularGauge>
                                                            <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Center" >
                                                                <TextBlock FontWeight="Light" FontSize="7" HorizontalAlignment="Center" VerticalAlignment="Bottom"  >SOH</TextBlock>
                                                                <TextBlock FontWeight="Light" FontSize="7" HorizontalAlignment="Center" VerticalAlignment="Bottom" Text="{Binding SOH}" ></TextBlock>
                                                            </StackPanel>
                                                        </Grid>

问题所在

其实报错已经很明显了,但是我之前觉得是包的问题所以一筹莫展
经过一次又一次的尝试
发现value值写数据或者是写数字都是可以的
问题就处在tovalue 和fromvalue里面

<lvc:AngularSection FromValue=“{Binding SOH}” ToValue=“100” Fill=“white”/>
<lvc:AngularSection FromValue=“0” ToValue=“{Binding SOH}” Fill=“#0098FA”/>
我尝试将白色进度变成0到100作为底,并且放在了蓝色进度条的上面
因为渲染的时候先渲染上面的代码,如果白色在下面势必会盖住蓝色的进度条

然后只加了蓝色的进度条 从0开始
发现竟然不报错了

问题就处在白色进度条上的fromvalue

正确代码

<Grid >

                                                            <lvc:AngularGauge  Value="{Binding SOH}" FromValue="0" ToValue="100" 
                                                             LabelsStep="50" TicksStep="10" Wedge="230" TicksStrokeThickness="0.2"
                                                            TicksForeground="Black" Foreground="black"  
                                                             FontWeight="thin" FontSize="6"
                                                            SectionsInnerRadius=".8">
                                                                <lvc:AngularGauge.Sections>
                                                                    <lvc:AngularSection FromValue="0" ToValue="100" Fill="white"/>
                                                                    <lvc:AngularSection FromValue="0" ToValue="{Binding SOH}" Fill="#0098FA"/>
                                                                    
                                                                </lvc:AngularGauge.Sections>
                                                            </lvc:AngularGauge>
                                                            <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Center" >
                                                                <TextBlock FontWeight="Light" FontSize="7" HorizontalAlignment="Center" VerticalAlignment="Bottom"  >SOH</TextBlock>
                                                                <TextBlock FontWeight="Light" FontSize="7" HorizontalAlignment="Center" VerticalAlignment="Bottom" Text="{Binding SOH}" ></TextBlock>
                                                            </StackPanel>
                                                        </Grid>
```问题解决
![在这里插入图片描述](https://img-blog.csdnimg.cn/9b1b72c22cc745cdbb102b6f18a643c3.png)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值