我的应用程序中有几个XamDataGrids,我希望所有这些都在用户更改其中的复选框后立即启用相应的"保存"按钮.这个目前不会发生,直到我离开单元格或按回车等,因为单元格仍处于编辑模式.我知道如何使用我在代码隐藏中找到的帖子来解决这个问题:
private void XamDataGrid_CellChanged(object sender, Infragistics.Windows.DataPresenter.Events.CellChangedEventArgs e)
{
e.Cell.Record.SetCellValue(e.Cell.Field, e.Editor.Value, true);
}
Run Code Online (Sandbox Code Playgroud)
但是,如何在整个应用程序中处理所有网格,而不是将其放在每个网格的代码隐藏中?我正在使用MVVM,如果可能的话,我希望不会有任何代码.如果我必须,我会,但我肯定不希望它在17个不同的网格文件背后的代码中.也许是一种行为?
我的应用程序 (Fredster) 有一个 ClickOnce 部署。它按用户安装在每个用户登录的服务器上。有时/不知何故,“开始”菜单开始添加 Fredster -1、Fredster -2 等。我认为这只是一个快捷方式,无论为任何用户单击“开始”菜单中的哪个图标,该应用程序似乎都能正常运行。但是为什么会发生这种情况,我如何避免添加这些令人困惑的“快捷方式”?当我在本地安装应用程序时,它永远不会发生。
在构建机器完成(TFS2017)构建后,最近开始从我的 VsTest 任务版本 2(版本 1 不产生警告)中收到以下警告:
Unable to get feature flag: TestExecution.EnableTranslationApi
Unable to get feature flag: TestExecution.EnableDiagnostics
Run Code Online (Sandbox Code Playgroud)
我创建了一个简单的构建定义,它有一个 VsTest 任务,但甚至没有任何测试,我遇到了同样的问题。这是它的日志:
2019-05-15T17:42:14.4932509Z ##[section]Starting: VsTest - testAssemblies
2019-05-15T17:42:14.4943225Z ==============================================================================
2019-05-15T17:42:14.4943357Z Task : Visual Studio Test
2019-05-15T17:42:14.4943570Z Description : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), …Run Code Online (Sandbox Code Playgroud) 我需要加快在我的应用程序中执行12个查询.我从常规foreach切换到Parallel.ForEach.但有时我会收到一条错误消息"ExecuteReader需要一个开放且可用的连接.连接的当前状态正在连接." 我的理解是,由于12个查询中的许多查询都使用相同的InitialCatalog,因此12中没有真正的新连接,这可能是问题所在?我怎样才能解决这个问题?"sql"是"Sql"类型的列表 - 类只是一个字符串名称,字符串connectiona和一个查询列表.这是代码:
/// <summary>
/// Connects to SQL, performs all queries and stores results in a list of DataTables
/// </summary>
/// <returns>List of data tables for each query in the config file</returns>
public List<DataTable> GetAllData()
{
Stopwatch sw = new Stopwatch();
sw.Start();
List<DataTable> data = new List<DataTable>();
List<Sql> sql=new List<Sql>();
Sql one = new Sql();
one.connection = "Data Source=XXX-SQL1;Initial Catalog=XXXDB;Integrated Security=True";
one.name = "Col1";
one.queries.Add("SELECT Name FROM [Reports]");
one.queries.Add("SELECT Other FROM [Reports2]");
sql.Add(one);
Sql two = new …Run Code Online (Sandbox Code Playgroud) 有什么方法可以将分隔符添加到数据绑定的WPF组合框中?即在我的xaml中,组合框的ItemsSource =“ {Binding TheList}”。该列表是一个可观察的对象集合,我要与其余对象分开。该列表也是从sql生成的,因此它不是硬编码或其他任何内容。我也不想选择seaprator。谢谢!
如何根据用户选择告诉我的TextBox绑定到不同的属性.我的情况是:
客户具有以下属性:
编辑或创建这些时,有一个单选按钮,用于选择要编辑的地址.因此,当我单击"邮件地址"单选按钮时,我想将TextBox绑定到属性" MailAddress",但是当单击"运送地址"时,我想将绑定更改为" ShipAddress"属性.
我知道我可以在Address单击单选按钮时设置一个属性" ",但我想直接绑定到Customer.MailAddress或Customer.ShipAddress用于验证目的(邮件地址是必需的,但船舶地址不是).
我需要检查整数是否有6个字符,如果是,则删除前三个字符并返回结果整数.否则,只返回原始整数.这就是我所拥有的,我想知道C#中是否有更好/更快/更有效的方式?
public static int MyMethod(int originalInt)
{
int outputInt = originalInt;
string temp = originalInt.ToString();
if (temp.Length == 6)
{
temp = temp.Substring(3);
if (!Int32.TryParse(temp, out outputInt))
{
outputInt = originalInt;
}
}
return outputInt;
}
Run Code Online (Sandbox Code Playgroud) 我不明白为什么在我的以下示例中,"Billing Model"组合框在文本框中没有显示属性BillingModel.BillingModelDescription.选择客户端后,我希望组合框显示当前的billng模型描述,但它保持空白.绑定到同一事物的文本框确实显示了描述.我有一些可能的模型作为ItemsSource,它工作正常.如何在选择客户端时更新计费模型组合框?
这是XAML:
<Window x:Class="WpfApplication7.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Client"/>
<ComboBox ItemsSource="{Binding AllClientData}" DisplayMemberPath="EmployerStr"
SelectedItem="{Binding SelectedClient}"
Width="300"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Billing Model:"/>
<ComboBox ItemsSource="{Binding AllBillingModels}" DisplayMemberPath="BillingModelDescription"
SelectedItem="{Binding SelectedClient.BillingModel}"
Width="300"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Billing Model" />
<TextBox Text="{Binding SelectedClient.BillingModel.BillingModelDescription}" Width="200"/>
</StackPanel>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
代码隐藏(这只是一个例子,我在完整的应用程序中使用MVVM等,但这是我用来说明问题):
public partial class MainWindow : Window, INotifyPropertyChanged
{
public MainWindow()
{
AllClientData = new ObservableCollection<ClientRate>();
AllBillingModels = new ObservableCollection<BillingModelType>();
ClientRate uno = new ClientRate();
uno.BillingModel = new BillingModelType();
uno.BillingModel.BillingModelID = 3; …Run Code Online (Sandbox Code Playgroud) 尝试以编程方式发送带有封面的传真.我在RightFax(v10.0)中制作了自定义封面,但代码似乎没有选择它,即使我设置了FCSFileName,它仍然使用管理实用程序中选择的封面页作为默认值.
FaxServer faxServer = new FaxServer();
faxServer.ServerName = "XXX-XX1";
faxServer.Protocol = CommunicationProtocolType.cpNamedPipes;
faxServer.UseNTAuthentication = BoolType.True;
Fax fax = (Fax)faxServer.get_CreateObject(CreateObjectType.coFax);
fax.ToName = "xxxx";
fax.ToFaxNumber = "xxxxxxxxxx";
fax.ToCompany = "XXX, Inc";
fax.FromName = "xxxxx";
fax.HasCoversheet = BoolType.True;
fax.FCSFilename = faxServer.CoverSheets[6].LongFileName; //only example of setting the cover sheet i could find online so far
fax.Attachments.Add(@"c:\Some Invoice.pdf", BoolType.False);
fax.Send();
Run Code Online (Sandbox Code Playgroud)