是否可以将绘图绑定到LineSeries集合而不是OxyPlot中的单个LineSeries?(而不是通过模型).
我正在寻找这样的东西:
<oxy:Plot>
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding myCollectionOfLineSeries}" />
</oxy:Plot.Series>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)
myCollectionOfLineSeries的位置是:
private ObservableCollection<LineSeries> _myCollectionOfLineSeries ;
public ObservableCollection<LineSeries> myCollectionOfLineSeries
{
get
{
return _myCollectionOfLineSeries ;
}
set
{
_myCollectionOfLineSeries = value;
OnPropertyChanged("myCollectionOfLineSeries ");
}
}
Run Code Online (Sandbox Code Playgroud)
我希望得到答案:a)"不,这是不可能的"或b)"是的,只是把XYZ放在IJK之前".
谢谢阅读.
我是线程用法的初学者,在我看过的例子中(这里和这里)必须为方法分配一个新线程.但是,有没有办法在方法中制作它?我正在寻找这样的东西:
public void MyMethod()
{
//Start new thread that affects only this method
//Do stuff
//More stuff
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
问题
我在3D WPF库中使用简单的线条显示几何体.在下一张图片中可以看到它的一个例子:

在其中,您可以看到一组三角形和四边形.我正在绘制这个的方式是我提供了一个List<Point3D>我在其中放置代表每个段的点对.
问题是有很多重复的边缘,我想避免这种情况,因为这种类型的表示似乎非常需要资源.
迭代在Element包含N个顶点的每个点上生成点列表.它不知道是否共享特定边缘.
<p0, p1, p1, p2, p2, p333, p333, p89, p89, p2, p2, p1 ...>
想法是删除重复的对(注意顺序可能不一样).在上面的示例中,移除的对应该是最后一个(p2,p1),因为它表示与第二对点(p1,p2)相同的边.可能存在一对,两个或更多重复的点对.
我需要尽快做这个操作,性能在这里是最重要的.
思路
在列表中添加点时,我可以临时存储其中的两个,并检查列表是否已经包含它们,但这意味着每次添加一个点时都会查看列表,这对我来说似乎不是一个好主意(列表将包含几千点5000-50000).
我生成点列表的元素有几个具有唯一ID的节点,所以我认为可以通过创建一个Dictionary有序的Tuple<Point3D, Point3D>然后删除重复项来以某种方式使用它.
我还没有尝试过最后一个想法,因为我还不确定如何实现它,我想知道是否还有其他事情可以做.
我正在尝试以这种方式专门化模板:
class PropertyBase
{
public:
SfPropertyBase(string name)
{
Name = name;
}
virtual ~SfPropertyBase() {}
string Name;
virtual bool FromString(Object* obj, string str) = 0;
};
template< typename T>
class Property : public SfPropertyBase
{
public:
Property(string name) : SfPropertyBase(name)
{
//specific to Property stuff
}
template<typename U = T>
typename std::enable_if<(std::is_class<U>::value && std::is_pointer<U>::value), bool>::type
FromString(Object* obj, string str)
{
//do something
return true;
}
template<typename U = T>
typename std::enable_if<!std::is_class<U>::value || !std::is_pointer<U>::value), bool>::type
FromString(Object* obj, string str)
{
//do …Run Code Online (Sandbox Code Playgroud) 这对你来说可能是一个极其容易和愚蠢的问题,但我还没想到:我正在尝试读取具有不同通道(或源)数据的长文件.每个通道都有几个字段,例如它的名称,编号,日期,数据类型,然后是数据.我是编程的新手,所以我的第一个方法(也许是一个错误的方法)是创建一个名为"Channel"的类,然后当我读取文件时(使用StreamReader)我创建了类Channel的新对象每个频道.将有未知数量的频道,我的问题是我不知道如何在以后调用该数据.
public class Channel
{
public string name;
public int number= 0;
//more labels
//data...
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我写了类似的东西(在阅读循环内),每个新的频道:
...
line=file.ReadLine()
myChannel Channel = new Channel();
myChannel.name=line.Substring(10,20)
myChannel.number=line.Substring(20,30)
...
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在以后调用该数据(存储在每个频道的列表中)?我应该为每个创建的对象指定不同的名称吗?
我试过google但我找不到这个确切的问题.谢谢.
我有一个ObservableCollection按钮:
public partial class MainWindow : Window
{
public ObservableCollection<Button> myBtCollection { get; set; }
public MainWindow()
{
InitializeComponent();
myBtCollection = new ObservableCollection<Button>();
Button bot1 = new Button { Width = 200, Height = 25, Content = "Boton 1" };
Button bot2 = new Button { Width = 150, Height = 50, Content = "Boton 2" };
Button bot3 = new Button { Width = 100, Height = 100, Content = "Boton 3" };
myBtCollection.Add(bot1);
myBtCollection.Add(bot2);
myBtCollection.Add(bot3);
myBtCollection.Add(bot1);
myBtCollection.Add(bot3);
myBtCollection.Add(bot2); …Run Code Online (Sandbox Code Playgroud) 首先,我不知道这是否被称为"复制"一个对象,所以问题标题可能是错误的.我所拥有的是一个名为File的自定义类,它包含一堆列表(5-6个列表中的1000多个数字)和一些其他属性.我将所有文件都放在List中以便能够访问它们(LoadedFiles).
我的问题是:如果我正在写一个方法,我不想写:
DoSomeOperation(LoadedFiles[2]);
Run Code Online (Sandbox Code Playgroud)
但反而:
File file2 = new File();
file2 = LoadedFiles[2];
DoSomeOperation(file2);
Run Code Online (Sandbox Code Playgroud)
这是一种不好的做法吗?或者编译器足够聪明,知道它是同一个对象并直接从原始列表(LoadedFiles)访问它.
我需要创建一些项目并将其添加到弹出代码隐藏中。在 XAML 中很容易做到这一点:
<Popup StaysOpen="False">
<DockPanel>
//Items here
</DockPanel>
</Popup>
Run Code Online (Sandbox Code Playgroud)
我认为“孩子”是我需要添加项目的地方,但我在里面看不到任何“添加”、“项目”、“来源”或“内容”。有谁知道如何做到这一点?
Popup myPopup= new Popup();
myPopup.Child // ... need to add items there
Run Code Online (Sandbox Code Playgroud) 这应该很容易,但我没有找到我需要的信息.我想要的就像改变滑块的颜色一样简单:

我正在使用ModernUI,默认的条形颜色与我的背景非常相似,我想让它更轻一些.
我正在尝试实现一个切换按钮,允许用户在线性轴或对数轴之间进行选择.
为此,我在我的View中看到了这个ToggleButton:
<ToggleButton Width="40" Height="20" Margin="2" Grid.Row="1" Content="LogX" VerticalAlignment="Center" IsChecked="{Binding LogXChecked, Mode=TwoWay}"/>
Run Code Online (Sandbox Code Playgroud)
在我的ViewModel中:
private bool _isLogXChecked;
public bool IsLogXChecked
{
get
{
return _isLogXChecked;
}
set
{
_isLogXChecked = value;
RaisePropertyChanged("IsLogXChecked");
LogX();
}
}
Run Code Online (Sandbox Code Playgroud)
但是使用这个实现我无法使它工作,当用户按下ToggleButton时,IsLogXChecked属性不会更新,并且我的方法LogX()不会触发.
哪里可能是问题?或者我应该如何将ToggleButton绑定到bool?谢谢.
c# ×9
wpf ×6
binding ×1
boolean ×1
c++ ×1
class ×1
duplicates ×1
enable-if ×1
list ×1
overriding ×1
oxyplot ×1
plot ×1
popup ×1
slider ×1
stackpanel ×1
templates ×1
togglebutton ×1
xaml ×1