我有一个用 WPF MVVM 编写的程序,并且有一个使用 DataVisualization Chart 库(DVC.dll)在我的View上显示图形的视图。
在我的ViewModel中,我有几个ObservableCollections<>,其中包含正好反映在图表上的数据点,但使用几分钟后,图表开始显示以前图表的“幽灵”点,并且直到我重新启动整个程序后才会刷新。
我尝试在每个集合更新新点之前使用 Clear() 函数,并在更改集合中的数据时添加一个小的 Thread.Sleep() 延迟,但没有任何帮助。
有什么解决办法吗?
看法:
<DVC:Chart Title="Cross Section" Background="LightSteelBlue" Height="385" >
<DVC:Chart.Series>
<!--Ground Line-->
<DVC:LineSeries IsSelectionEnabled="True" IndependentValueBinding="{Binding Path=X}"
SelectedItem="{Binding SelectedPointOnGraph, Mode=TwoWay}"
DependentValueBinding="{Binding Path=Y}" ItemsSource="{Binding HydroPoints, BindsDirectlyToSource=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TransitionDuration="0">
<DVC:LineSeries.DataPointStyle>
<Style TargetType="{x:Type DVC:LineDataPoint}">
<Setter Property="Background" Value="SaddleBrown" ></Setter>
<Setter Property="Opacity" Value="2" />
<Setter Property="ToolTip" Value="{Binding Path=Coordinate}" />
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="DVC:LineDataPoint">
<Grid>
<Ellipse Fill="{TemplateBinding Background}" />
<Canvas>
<TextBlock FontWeight="Bold"
Text="{Binding Path=PointNote, …Run Code Online (Sandbox Code Playgroud) 我有一个有线问题,我正在使用protobuf-net为C#生成一个基于Google Protocol Buffer消息的文件,然后将其上传到我公司的一个服务器.
我在C#中创建了一个生成.cs文件的工具,然后我使用它的类(来自.cs文件)来填充消息中的所有必填字段,之后我调用了Serializer.Serialze()函数它为我创建了所需的文件.
但是,这就是问题,我有另一个文件(同一个文件)在另一个用C++编写的工具中创建(使用我使用的相同.proto文件),但是当我试图将我的文件上传到我们的服务器时我收到一个错误的错误.
我将这2个文件与"Win Merge"软件进行了比较,我注意到与C++工具中生成的文件相比,3个不同行(每个文件中7000行以外)的差异很小.
下面是从Win Merge工具捕获的2行示例(在C++左侧,在右侧C#上):


我注意到差异在于矩形(我不明白它有什么意义)和它们内部的字节...
这是我正在使用的.proto文件:
message Package {
message ArchDepend {
message Arch {
required string version = 1;
required string description = 2;
}
message Firmware {
required string version = 1;
required string description = 2;
required bytes file = 3;
repeated string from_version = 4;
}
message Rsu {
required string version = 1;
required string description = 2;
required bytes file = 3;
}
required Arch arch = 1;
optional …Run Code Online (Sandbox Code Playgroud) 我是正则表达式使用的新手,在2天内我正在搜索如何从字符串中提取特定数据,但没有成功.
这个字符串是一个较长字符串的部分字符串,我需要找到一个参数,然后获取它的值:
\rRoll Off = 0.25\rSINE = OFF\rSymbol Rate = 1.000000\rBit Rate = 1.322253
Run Code Online (Sandbox Code Playgroud)
目标:找到参数 Symbol Rate并使用C#通过正则表达式获取其值 1.000000(只需存储该值).
如果有人可以帮我解决这个问题,将会非常有帮助.
谢谢!
我有一个主窗口,其中包含一些在 WPF XAML
MainWindow.xaml中初始化的用户控件。
<Grid>
<local:RegularUnit x:Name="ucRegularUnit" Grid.Row="0" />
<local:Actions x:Name="ucActions" Grid.Row="1" />
// .....
</Grid>
Run Code Online (Sandbox Code Playgroud)
我在主窗口中有一个公共函数,我想在单击用户控件中的按钮后调用它。在搜索了一些解决方案后,我找到了一种在我的用户控件类中获取父窗口实例的方法,但是在我使用parentWindow.myFunction().
用户控制RegularUnit.cs:
public partial class RegularUnit : UserControl
{
public RegularUnit()
{
InitializeComponent();
}
private void Button_SearchSerialNumber_Click(object sender, RoutedEventArgs e)
{
Window parentWindow = Window.GetWindow(this);
//parentWindow. //Can't find the function myFunction()
}
}
Run Code Online (Sandbox Code Playgroud)
MainWindow.cs:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void myFunction()
{
// Do Some Stuff...
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么,我该如何解决?