这是第一个程序中的代码的一部分,我开始第二个程序。
private void ExecuteStartCacherCommand(object parameter)
{
try
{
StringBuilder sb = new StringBuilder();
sb.Append("\"" + ProductCode.BoxName + "\""); sb.Append(" ");
sb.Append(LengthText); sb.Append(" ");
sb.Append(WidthText); sb.Append(" ");
sb.Append(HeightText); sb.Append(" ");
sb.Append(L1); sb.Append(" ");
sb.Append(L2); sb.Append(" ");
sb.Append(StampTotalPrice);
string arg = sb.ToString();
Process p = new Process();
p.StartInfo.FileName = "CacherPrices.exe";
p.StartInfo.Arguments = arg;
p.Start();
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
}
}
这是第二个程序中代码的一部分。
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
try
{
string[] args = new string[10];
ArgsIncome ai;
if (e.Args.Length > 0)
{
for (int i = 0; i < e.Args.Length; i++)
{
args[i] = e.Args[i];
}
ai = ArgsIncome.getSampleOfDataBase();
ai.Name = args[0];
ai.Length = args[1];
ai.Width = args[2];
ai.Height = args[3];
ai.L1 = args[4];
ai.L2 = args[5];
ai.Stamp = args[6];
}
else
ai = ArgsIncome.getSampleOfDataBase();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
// загружаем главное окно.
View.MainWindow window = new View.MainWindow();
this.MainWindow = window;
window.Show();
}
问题: 当我从第一个程序开始第二个程序时,我所有的绑定都消失了。 当我使用args在debug中启动第二个程序时,一切都是O.K. 当我评论args发送第一个程序并在没有它们的情况下开始第二个时,一切都是O.K.
其他信息
public class ArgsIncome
{
public string Name { get; set; }
public string Length { get; set; }
public string Width { get; set; }
public string Height { get; set; }
public string L1 { get; set; }
public string L2 { get; set; }
public string Stamp { get; set; }
private ArgsIncome()
{
Name = "Тип";
Length = "0";
Width = "0";
Height = "0";
L1 = "0";
L2 = "0";
Stamp = "0";
}
private static readonly object padlock = new object();
private static ArgsIncome dataBase = null;
public static ArgsIncome getSampleOfDataBase()
{
if (dataBase == null)
{
lock (padlock)
{
if (dataBase == null)
{
dataBase = new ArgsIncome();
}
}
}
return dataBase;
}
}
绑定示例
<TextBox Margin="5" Width="75" Text="{Binding Path=StampPrice,UpdateSourceTrigger=PropertyChanged}"/>
string _stampPrice;
public string StampPrice
{
get
{
if (_stampPrice == null)
_stampPrice = _ai.Stamp;
return _stampPrice;
}
set
{
_stampPrice = value;
}
}
class MainWindowViewModel : ViewModelBase{}
public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable{}