小编per*_*ife的帖子

WPF TextBlock文本绑定

TextBlock绑定不起作用,我不知道为什么......

(此代码有效,但TextBlock未更新)

XAML

<TextBlock x:Name="filterAllText"
 Text="{Binding UpdateSourceTrigger=PropertyChanged}" />
Run Code Online (Sandbox Code Playgroud)

代码隐藏

filterAllText.DataContext = LogSession.test.MyCoynt;
Run Code Online (Sandbox Code Playgroud)

C#

public class Test : INotifyPropertyChanged {
 public int myCoynt;

     public int MyCoynt {
        get { return myCoynt; }
        set {
            myCoynt = value;
            NotifyPropertyChanged();
        }
    }

     public event PropertyChangedEventHandler PropertyChanged;

     protected virtual void NotifyPropertyChanged(
        [CallerMemberName] String propertyName = "") {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null) {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
}
Run Code Online (Sandbox Code Playgroud)

c# data-binding wpf user-controls

6
推荐指数
1
解决办法
3万
查看次数

如何将foreach转换为Parallel.ForEach?

如何转换:

  foreach (  NotifyCollectionChangedEventHandler handler in delegates) {
            ...
  }
Run Code Online (Sandbox Code Playgroud)

像这样的东西

 Parallel.ForEach(    NotifyCollectionChangedEventHandler handler in delegates) {
  ... 
 }
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library

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

检查字符串的第一个元素是否为正整数

我需要检查字符串的第一个元素是否是C#中的正整数.有一个聪明的方法来做到这一点?FX

string str = "2001";
if (str.First() == isANumber) {
...                                
}
Run Code Online (Sandbox Code Playgroud)

c# string parsing

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