我一直在研究WPF应用程序,它本质上是一个WYSIWYG编辑器,并且正在使用拖放功能.我有拖放功能,但需要使其更直观和用户友好.部分内容涉及实际显示被拖动的项目.最简单的方法是什么?我拖的项目并不特别,但我甚至不确定在哪里寻找如何做到这一点.
我正在使用WPF应用程序,我正在开发一个DataGrid,它包含了必须对事件做出反应的动态内容的使用等.
我有包含DataGrid的View的以下ViewModel
public class HiddenFieldPanelViewModel
{
public List<HiddenFieldComponent> HiddenFieldList { get; set; }
public HiddenFieldComponent Component { get; set; }
public bool IsVisible { get; set; }
public enum FieldTypes{Constant,Variable}
public HiddenFieldPanelViewModel()
{
HiddenFieldList = new List<HiddenFieldComponent>();
IsVisible = false;
}
}
Run Code Online (Sandbox Code Playgroud)
此模型上适用于此示例的唯一属性是以下枚举属性
public enum FieldTypes {Constant,Variable}
Run Code Online (Sandbox Code Playgroud)
填充DataGrid时我需要做的是将枚举类型绑定到DataGrid单元格中的下拉列表,这里是添加它之后的一个DataGrid集合项的示例

例如,在上图中,我希望它具有FieldTypes枚举中的两个Enum值.
在我的XAML中,我指定了以下内容:
<DataGridTemplateColumn Header="Field Type" CanUserResize="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Height="20" SelectedIndex="0" ItemsSource="{Binding Path=FieldTypes}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Label Content="{Binding Path=Value}"></Label>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
其他列正确绑定数据,但这不是.
我不确定是否有更好的方法来做到这一点.我还从IValueConverter编写了一个EnumConverter来处理字符串枚举字符串转换(如果需要的话).
谢谢
所以这可能是一个非常基本的问题,但我正在将ListBox项拖放到一个面板上,该面板将根据值创建组件.
作为一个简单的例子,我需要它能够在ListBox中的项目被放到面板上时在面板上创建一个新的Label.
我有以下代码,但不知道如何在删除后动态地将Label添加到面板.
这是我的示例代码......
namespace TestApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
listBox1.Items.Add("First Name");
listBox1.Items.Add("Last Name");
listBox1.Items.Add("Phone");
}
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
ListBox box = (ListBox)sender;
String selectedValue = box.Text;
DoDragDrop(selectedValue.ToString(), DragDropEffects.Copy);
}
private void panel1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void panel1_DragDrop(object sender, DragEventArgs e)
{
Label newLabel …Run Code Online (Sandbox Code Playgroud) 我有以下LINQ语句:
Items = Items.Where(p => p.LeadDatas.Any(
q =>
q.LeadField.Name == descriptor.Name &&
Convert.ToDouble(q.Value) == Convert.ToDouble(value)));
Run Code Online (Sandbox Code Playgroud)
它q.Value是double的String值,也是double value的String值,这两个值都需要转换为double,以便可以比较它们的相等性.
当我调试这个LINQ语句时,我得到以下SQLException:
错误将数据类型varchar转换为float
我不知道为什么它不允许我这样做,但我想知道修复是什么,我需要我的两个值来比较这里的平等.
我正在尝试使用StructureMap为我的MVC项目设置setter/property注入,但我似乎无法设置属性.我很清楚构造函数注入是推荐的做法,但我有一个严格的要求,要求我们使用setter注入,所以请保持评论试图告诉我否则.
我有正常的样板设置代码,例如我的Global.asax中的以下内容
ControllerBuilder.Current.SetControllerFactory(new TestControllerFactory());
ObjectFactory.Initialize(x => {
x.For<IPaymentService>().Use<PaymentService>();
x.ForConcreteType<HomeController>().Configure.Setter<IPaymentService>(y => y.PaymentService).IsTheDefault();
x.SetAllProperties(y =>
{
y.OfType<IPaymentService>();
});
});
Run Code Online (Sandbox Code Playgroud)
我的TestControllerFactory如下所示:
public class TestControllerFactory:System.Web.Mvc.DefaultControllerFactory
{
protected IController GetControllerInstance(Type controllerType)
{
if (controllerType == null)
throw new ArgumentNullException("controllerType");
return ObjectFactory.GetInstance(controllerType) as IController ;
}
}
Run Code Online (Sandbox Code Playgroud)
我有以下服务/实现类对
public interface IPaymentService
{
}
public class PaymentService:IPaymentService
{
}
Run Code Online (Sandbox Code Playgroud)
最后,我的控制器将具有需要将具体支付服务实现注入其中的属性:
public class HomeController:Controller {public IPaymentService Service {get; set;}
public ActionResult Index(){
var test = Service... //Service is Null
}
Run Code Online (Sandbox Code Playgroud)
}
如上所示,当我调试时,该属性保持为null.
另外,我尝试使用[SetterProperty]只是为了看它是否有效(我无意将控制器与这些属性耦合),它仍然没有用.
我不确定我是否需要做其他事情,或者问题可能是什么.我一直在使用StructMap的构造函数注入很长一段时间.
c# structuremap dependency-injection inversion-of-control asp.net-mvc-3
我有以下ElasticSearch查询,我认为会返回电子邮件字段中的所有匹配项,它等于myemails@email.com
"query": {
"bool": {
"must": [
{
"match": {
"email": "myemail@gmail.com"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
}
正在搜索的用户类型的映射如下:
{
"users": {
"mappings": {
"user": {
"properties": {
"email": {
"type": "string"
},
"name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"nickname": {
"type": "string"
},
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是从ElasticSearch返回的结果示例
[{
"_index": "users",
"_type": "user",
"_id": "54b19c417dcc4fe40d728e2c",
"_score": 0.23983537,
"_source": {
"email": "johnsmith@gmail.com",
"name": "John Smith",
"nickname": …Run Code Online (Sandbox Code Playgroud) 我面前有一本书,其中包含以下代码片段
int a = Character.getNumericValue('a');
int z = Character.getNumericValue('z');
int A = Character.getNumericValue('A');
int Z = Character.getNumericValue('Z');
System.out.println(a);
System.out.println(z);
System.out.println(A);
System.out.println(Z);
Run Code Online (Sandbox Code Playgroud)
然后,该示例继续使用这些值作为迭代的上限和下限,这意味着分配给a和的整数A具有不同的值,但是当我运行上面的代码时,我得到以下输出。
10
35
10
35
Run Code Online (Sandbox Code Playgroud)
我失去理智了吗?这不应该是输出四个不同的整数吗?
我遇到了一个奇怪的问题,grunt-ng-constant其中3个目标中只有2个起作用.
我的配置如下所示:
grunt.initConfig({
ngconstant: {
options: {
space: ' ',
wrap: '"use strict";\n\n {%= __ngModule %}',
name: 'config'
},
// Environment targets
development: {
options: {
dest: '<%= yeoman.app %>/scripts/config.js',
},
constants: {
ENV: {
name: 'development',
apiEndpoint: 'http://your-development.api.endpoint:3000'
}
}
},
staging: {
options: {
dest: '<%= yeoman.app %>/scripts/config.js',
},
constants: {
ENV: {
name: 'staging',
apiEndpoint: 'http://your-staging.api.endpoint:3000'
}
}
},
production: {
options: {
dest: '<%= yeoman.dist %>/scripts/config.js',
},
constants: {
ENV: {
name: 'production',
apiEndpoint: …Run Code Online (Sandbox Code Playgroud) 我已经设置了一个控制台应用程序,它只运行一个循环并使用Signal R发出一条消息.正在监听的客户端是一个角度应用程序.
当我在本地运行时(控制台应用程序和Angular站点)它运行正常.但是,当我在我的Vagrant VM(Ubuntu HOST)中运行我的控制台应用程序时,我得到一个非常熟悉的错误消息,如下所示:
GET http://localhost:12345/signalr/negotiate?clientProtocol=1.5&userId=12345&connectionData=%5B%7B%22
name%22%3A%22testem
itter%22%7D%5D&_=1446565284280 500 (Internal Server Error)
Run Code Online (Sandbox Code Playgroud)
我之前遇到过类似的问题(可能是这个问题),所以这里有一些初步细节
我的代码如下所示:
namespace test
{
public class Program
{
public static void Main(string[] args)
{
try
{
using (WebApp.Start<EmmitStartup>("http://*:12345"))
{
Console.Out.WriteLine("Emmit started on http://*:12345");
IEmitterFactory factory = new EmitterFactory();
while (true)
{
Thread.Sleep(5000);
ITestEmitter emitter = factory.Create((ctx) =>
{
return new TestEmitter(ctx);
});
emitter.SayHello();
emitter.Echo("Hello World:" + DateTime.Now);
}
}
}
catch (Exception e)
{
Console.Out.WriteLine(e.Message);
Console.Out.WriteLine(e.StackTrace);
Console.ReadLine();
}
}
}
public class TestEmitter:Emitter,ITestEmitter
{
public TestEmitter(IEmitterContext …Run Code Online (Sandbox Code Playgroud) 我正在使用Winforms DevExpress,我正在将DataTable绑定到DataGridView,它正常工作.我遇到的问题是我有一些函数将构建一个新的DataTable对象,该对象与原始文件分开,需要替换绑定到DataGridView的原始DataTable.
DataTable originalTable = new DataTable("OriginalTable");
//Populate originalTable
myDataGridControl.DataSource = originalTable;
Run Code Online (Sandbox Code Playgroud)
使用上面的代码一切正常,但下面的代码创建一个新的DataTable,需要设置为myDataGridControl的DataSource.
DataTable newTable = new DataTable("NewTable");
//Populate newTable
//Set newTable as the DataSource for myDataGridControl
myDataGridControl.DataSource = newTable;
Run Code Online (Sandbox Code Playgroud)
我尝试了几种不同的尝试来调用RefreshDataSource(),Refresh(),将DataSource设置为null.我还没有让它工作.我该怎么做呢?
c# ×6
.net ×2
winforms ×2
wpf ×2
angularjs ×1
asp.net ×1
char ×1
data-binding ×1
datatable ×1
devexpress ×1
gruntjs ×1
java ×1
javascript ×1
linq ×1
node.js ×1
owin ×1
signalr ×1
structuremap ×1
vagrant ×1
windows ×1