我需要选择json文件.
public void LoadChartData()
{
var ofDialog = new System.Windows.Forms.OpenFileDialog { Filter = @"json (*.json)|*.json" };
if (ofDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{ }
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,编译此代码会返回错误(每次两次System.Windows.Forms):
Error CS0234 The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
如何处理这个错误?
我需要绑定颜色来填充矩形.
XAML:
<Rectangle Fill="{Binding Colorr}"
VerticalAlignment="Center"
Height="3" Width="16"
Margin="3, 1, 5, 0"
Visibility="Visible"/>
Run Code Online (Sandbox Code Playgroud)
视图模型:
public ItemViewModel()
{
Colorr = Colors.Red;;
}
public Color Colorr
{
get {
return color; }
set
{
color = value;
NotifyOfPropertyChange(() => Colorr);
}
}
Run Code Online (Sandbox Code Playgroud)
生成的矩形不可见(或透明 - 很难说......),而不是可见和红色.我该怎样摆脱这个问题?