小编Ric*_*key的帖子

TextBox - 绑定属性名称

我有一个TextBoxes列表,它们绑定到不同的属性.

<TextBox Text="{Binding Name, Mode=TwoWay,ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True}" VerticalAlignment="Center" Margin="5" Width="300" Grid.Column="1" Grid.Row="1" LostFocus="TextBox_Validate"/>
Run Code Online (Sandbox Code Playgroud)

我想写一个处理程序,如

private void TextBox_Validate(object sender, RoutedEventArgs e)
        {
            var textBox = (sender as TextBox);
            if(textBox!=null)
            {
                var propertyName = X; // Get propertyName textBox.Text is bound to.
                CurrentDataContext.ValidateFields("Name"); // Name in this specific textBox
            }
        }
Run Code Online (Sandbox Code Playgroud)

是否有可能获得属性的名称,所以我不必编写许多不同的方法来做同样的事情?

c# data-binding silverlight binding

2
推荐指数
1
解决办法
1556
查看次数

关于LINQ to SQL的简单问题

我无法理解一件事.假设我已经拥有这些编码实体:

[Table(Name = "Rates")]
public class Rate
{
    private EntityRef<Product> _Product;

    [Column(IsPrimaryKey = true)]
    public String RateID 
    { get; set; }
    [Column]
    public String ProductID 
    { get; set; }
    [Column]
    public Double VolumeInTons 
    { get; set; }
    [Column]
    public Decimal Volume 
    { get; set; }
    [Column]
    public Decimal Cost 
    { get; set; }
    [Column]
    public UInt32 Year 
    { get; set; }

    [Association(Storage = "_Product", OtherKey = "ProductID")]
    public Product Product
    {
        get { return this._Product.Entity; }
        set { this._Product.Entity = …
Run Code Online (Sandbox Code Playgroud)

c# database database-connection linq-to-sql

2
推荐指数
1
解决办法
76
查看次数

C#中的定时器问题

System.Windows.Forms.Timer在我的项目中使用了两个对象,如下所示.

private void Form1_Load(object sender, EventArgs e)
{
    timer1.Interval = 60000;
    timer2.Interval = 62000;
    timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)
{
    Console.WriteLine("Timer1 :" + DateTime.Now.ToString());
    timer2.Start();
}

private void timer2_Tick(object sender, EventArgs e)
{  
    Console.WriteLine("Timer2 :" + DateTime.Now.ToString());
    timer2.Stop();
}
Run Code Online (Sandbox Code Playgroud)

输出结果是:

Timer1 :05/30/2011 12:15:57 AM      (12:16:59)
Timer1 :05/30/2011 12:16:57 AM      (12:17:59) miss
Timer2 :05/30/2011 12:16:59 AM      

Timer1 :05/30/2011 12:17:57 AM      (12:18:59)
Timer1 :05/30/2011 12:18:57 AM      (12:19:59) miss
Timer2 :05/30/2011 12:18:59 AM

Timer1 :05/30/2011 12:19:57 AM      (12:20:59) …
Run Code Online (Sandbox Code Playgroud)

.net c# timer winforms

2
推荐指数
1
解决办法
830
查看次数

C#循环浮点数的正确方法

我循环一个看起来像这样的函数:

Y=exp(-0.04*(x-13.25)^(2))*300
Run Code Online (Sandbox Code Playgroud)

假设我想获得Y每个值x在3.3454和20.3458之间的每个值0.1 interval

我会这样做:

for (float i=3.3454;i<20.3458;i=+.1)
Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?

c#

1
推荐指数
2
解决办法
4452
查看次数

如何在c#桌面应用程序中隐藏窗口?

我正在尝试制作一个隐藏的桌面应用程序,但只会在一段时间后显示.我试图在窗口加载事件中设置Visible = false但它仍然显示.

c# desktop-application windows-7 winforms

0
推荐指数
1
解决办法
3426
查看次数