我有一个DataGrid显示在XAML中定义的客户列表,如下所示绑定到我的ViewModel:
<DataGrid Name="CustomersDataGrid" ItemsSource="{Binding Customers}">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Command="{Binding showCustomerCommand}"
Content="{Binding Path=Name}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)
网格的显示效果很好.我希望能够显示单个客户的详细信息.以前,我为所选行设置了绑定,并在页面上有一个按钮,该按钮绑定到以下命令:
RelayCommand _showCustomerCommand;
public ICommand showCustomerCommand
{
get
{
if (_showCustomerCommand == null)
{
_showCustomerCommand = new RelayCommand(param => this.ShowCustomer());
}
return _showCustomerCommand;
}
}
private void ShowCustomer()
{
if (Parent != null)
{
// Handle Customer Display Here
}
}
Run Code Online (Sandbox Code Playgroud)
这很好.但我希望能够单击单个行内的按钮,而不是基于所选行的单个按钮.我知道上面的XAML中的datacontext是错误的,但我不知道如何纠正它,也不知道如何传递按钮按下的特定行.非常感谢任何和所有建议,以帮助我连接我的嵌入式按钮!
我正在尝试创建我正在考虑的翻译类,以便我的程序可以与各种目标平台对话.每个平台都将由抽象类的单独实现处理.为了简单起见,我减少了一些东西.
我有一个抽象类,有几个抽象方法:
abstract class ControllerBase
{
public abstract bool EnableDTMFDetection(string CallID, Party Party);
public abstract bool DisableDTMFDetection(string CallID, Party Party);
}
Run Code Online (Sandbox Code Playgroud)
随后是一个派生自ControllerBase的类(类),并完全实现这些方法:
class PlatformOne : ControllerBase
{
public override bool EnableDTMFDetection(string CallID, Party Party)
{
// Do Stuff
return true;
}
public override bool DisableDTMFDetection(string CallID, Party Party)
{
// Do Stuff
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.对于PlatformOne,我被迫定义每个方法,规定如何将传出消息发送到目标平台.
是我的传入事件.我需要能够从派生类中引发事件.当我将以下内容添加到controllerbase时:
public delegate void MyEventHandler(object sender, EventArgs e);
public event MyEventHandler MyEvent;
Run Code Online (Sandbox Code Playgroud)
它编译得很好,但我不能在我的派生类中引发事件而没有错误:"事件'ControllerBase.MyEvent'只能出现在+ =或 - =的左侧(除非在输入'ControllerBase')"
那么,a)如何从我的派生类中引发我的事件,以及b)是否有人可以建议一种机制来强制从我的派生类(抽象函数或接口方法)中强制指定事件的连接.谢谢你致电:)
我正在尝试从独立的UCMA应用程序到SIP提供商(Gamma)进行出站呼叫,该提供商根据连接的IP地址进行身份验证.以下是我试图实现此目的的代码(直接取自Michael Greenlee(http://blog.greenl.ee/2012/06/15/outbound-calls-ucma-lync-server/):
ApplicationEndpointSettings endpointSettings =
new ApplicationEndpointSettings("sip:02037571***@80.229.80.***"); // My Ext. IP
...
CallEstablishOptions options = new CallEstablishOptions();
options.ConnectionContext = new ConnectionContext("88.215.61.***", 5060); // Gamma Ext. IP
Conversation conv = new Conversation(_endpoint);
AudioVideoCall avcall = new AudioVideoCall(conv);
avcall.BeginEstablish("sip:07709411***@88.215.61.***", options,
ar2 =>
{
try
{
avcall.EndEstablish(ar2);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
},
null);
Run Code Online (Sandbox Code Playgroud)
尝试拨号失败,Gamma返回403 Forbidden-Source Endpoint Lookup Failed.
我已经将wireshark跟踪与此尝试失败以及可以成功拨出的硬件PBX进行了比较.
工作硬件PBX:
From: "02037571***"<sip:02037571***@80.229.80.***>;tag=39E432463135364100006C30
SIP Display info: "02037571***"
SIP from address: sip:02037571040@80.229.80.***
SIP from address User Part: 02037571***
SIP from …Run Code Online (Sandbox Code Playgroud) 简单的句法c#问题是这个.
鉴于此代码:
List<string> Columns = new List<string>();
List<string> Parameters = new List<string>();
List<string> Values = new List<string>();
Run Code Online (Sandbox Code Playgroud)
它可以简化为:
List<string> Columns = new List<string>(), Parameters = new List<string>(), Values = new List<string>();
Run Code Online (Sandbox Code Playgroud)
但是我可以将它缩短,因为它们都被初始化为空列表吗?
谢谢你们!
我有以下在.NET Core 2中成功运行的方法,但在.NET Core 3中却无效。
我从头开始制作了一个新的Worker Service .Net Core 3项目,并仅添加了最少的内容来重新创建我的错误。
这是我在Program.cs中的入口
namespace WorkerService1DeleteMe
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.Configure<ConfigChunk>(hostContext.Configuration.GetSection("ConfigChunk"));
services.AddHostedService<Worker>();
});
}
public class ConfigChunk
{
public string Server { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
因此CreateHostBuilder,在此Configure方法中添加了一行代码ConfigChunk,在底部添加了一个新类,以匹配appsettings.json中某个部分的模式。
最后,将参数扩展到Worker构造函数,以使其使用SettingsChunk:
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
private readonly ConfigChunk _config; …Run Code Online (Sandbox Code Playgroud)