我正在我的存储库中实例化我的存储库MainViewModel
,并将此实例传递给我的孩子ViewModel
(即CategoryViewModel
)。我得到了
严重性代码 说明 项目文件行错误 类型“CategoryViewModel”不包含任何可访问的构造函数。
该错误来自我的主窗口,我在其中声明了类别用户控件并将其设置DataContext
为CategoryViewModel
:
<view:CategoryView Grid.Row="2" Grid.Column="0" Margin="5">
<view:CategoryView.DataContext>
<viewModel:CategoryViewModel />
</view:CategoryView.DataContext>
</view:CategoryView>
Run Code Online (Sandbox Code Playgroud)
当构造函数中没有任何参数时,我不会收到此错误CategoryViewModel
,因此我知道它与此有关,但不确定是什么导致了问题。我将不胜感激任何建议。下面是我的MainViewModel
和CategoryViewModel
.
public class MainViewModel : BindableBase
{
private readonly IRepository _repo = new Repository();
private CategoryViewModel _categoryViewModel;
public MainViewModel()
{
_categoryViewModel = new CategoryViewModel(_repo);
}
}
public class CategoryViewModel : BindableBase
{
private IRepository _repo;
public List<Category> CategoryCollection { get; set; }
public CategoryViewModel(IRepository repo)
{
_repo = repo; …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Visual Studio 2015。我打开了我的工具箱并检查了Show All。我取消选中此选项,现在我的整个工具箱都是空的,除了“常规”选项卡(其中没有任何内容)。我尝试重置工具箱,但这并没有解决问题。有没有人遇到过这个?如果是这样,修复方法是什么?谢谢。
我正在开发一个 WPF 应用程序,目前我有一个ItemsControl
绑定到我的视图模型ObservableCollection
,我有一个DataTemplate
使用 aUserControl
在canvas
. 您可以使用多个用户控件,然后根据一个来切换使用哪个Enum
?另一种查看它的方法是为基于的项目创建 aButton
或 a 。TextBox
ObservableCollection
Enum
有谁知道如何改变氧标图上的分割标记的颜色?我似乎无法在任何地方找到那个特定的财产.这是我用来制作下图的代码.如您所见,分割标记是黑色的.真想改变自己的颜色.谢谢.
<oxy:Plot PlotAreaBorderColor="White" Background="#242426" TextColor="White" Margin="5" Title="X and Y FPOS" TitleFontSize="12" Grid.Row="0" Grid.ColumnSpan="2">
<oxy:LineSeries ItemsSource="{Binding XYData}"/>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)
我正在尝试将double [,]转换为一个字符串[],如下面的代码所示
double[,] completeDataArray = new double[25,4000];
string[] tarray = new string[4000];
for(int i = 0;i<4000;i++)
{
tarray[i]=string.Join(",",Convert.ToString(completeDataArray[24,i]));
}
Run Code Online (Sandbox Code Playgroud)
`
当我在视觉工作室中这样做时,一切都按预期工作.但是在sharpDevelop中,我得到了这两个错误
(1)'string.Join(string,string [])'的最佳重载方法匹配有一些无效参数和(2)参数2:无法从'string'转换为string []'
我能让它工作的唯一方法是使用另一个字符串数组.
double[,] completeDataArray = new double[25,4000];
string[] tarray = new string[4000];
string[] tempString = new string[4000];
for(int i=0;i<4000;i++)
tempString[i]=convert.toString(completeDateArray[24,i]);
for(int i = 0;i<4000;i++)
tarray[i]=string.Join(",",tempString);
Run Code Online (Sandbox Code Playgroud)
我遇到的唯一问题是我的内存不足,当我使用tempString时出现内存不足错误.
谁能告诉我我做错了什么?
我有一些代码要运行,直到我请求取消为止。
Task.Run(() =>
{
while (!token.IsCancellationRequested)
{
GetFeedbackTask();
}
}, token);
Run Code Online (Sandbox Code Playgroud)
然后我执行这个方法token.Cancel()
。这将按预期取消任务,按预期取消我的 while 循环。问题是当我在取消token.IsCancellationRequested
属性后再次尝试运行 Task 时true
。是什么设置了属性false
?我需要Dispose
令牌吗?
c# ×4
wpf ×2
.net ×1
cancellation ×1
data-binding ×1
datatemplate ×1
mvvm ×1
oxyplot ×1
sharpdevelop ×1
task ×1
toolbox ×1