我参考这种方式,并创建我的DataGrid.
但我在调用命令时需要使用参数。
我看到这是一种MS.Internal.Data.CollectionViewGroupInternal类型,但我不知道如何转换它。
“MS.Internal.Data.CollectionViewGroupInternal”有项目及其名称,我如何获取它?或者,我可以将我的参数绑定到CommandParameter,也许像SelectedItemof DataGrid,因为我有一个DependencyPropertyfor click Expander。
public class ExpanderDataGrid : DataGrid
{
public string SelectedExpanderName
{
get
{
return (string)GetValue(SelectedExpanderNameProperty);
}
set
{
SetValue(SelectedExpanderNameProperty, value);
}
}
public static readonly DependencyProperty SelectedExpanderNameProperty = DependencyProperty.Register("SelectedExpanderName",
typeof(string), typeof(ExpanderDataGrid),
new FrameworkPropertyMetadata("",
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
}
Run Code Online (Sandbox Code Playgroud) 我已经看到了两种图表用法,PlotView和Plot。
如果使用PlotView,则只能使用Model="{Binding MyModel}",不能设置其他绑定,例如source。我无法实现MVVM。
但是,如果使用Plot,我可以进行任何绑定,并且xaml中的许多子控件设置都可以像series,axes等等。
我可以知道有什么不同吗?
在 .NET Framework 中,有Dictionary和ConcurrentDictionary. 这些提供诸如Add,Remove等方法...
我知道当我们设计一个多线程程序时,我们使用ConcurrentDictionary来代替Dictionary线程安全。
我不知道为什么ConcurrentDictionary有AddOrUpdate,GetOrAdd和类似的方法,同时Dictionary也没有。
我们总是喜欢下面的代码从 a 获取对象Dictionary:
var dict = new Dictionary<string, object>();
object tmp;
if (dict.ContainsKey("key"))
{
tmp = dict["key"];
}
else
{
dict["key"] = new object();
tmp = new object();
}
Run Code Online (Sandbox Code Playgroud)
但是在使用时ConcurrentDictionary,类似的代码只有一行。
var conDict = new ConcurrentDictionary<string, object>();
var tmp = conDict.GetOrAdd("key", new object());
Run Code Online (Sandbox Code Playgroud)
我希望 .NET 有这些方法,但为什么没有呢?