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) 如何转换:
foreach ( NotifyCollectionChangedEventHandler handler in delegates) {
...
}
Run Code Online (Sandbox Code Playgroud)
像这样的东西
Parallel.ForEach( NotifyCollectionChangedEventHandler handler in delegates) {
...
}
Run Code Online (Sandbox Code Playgroud) 我需要检查字符串的第一个元素是否是C#中的正整数.有一个聪明的方法来做到这一点?FX
string str = "2001";
if (str.First() == isANumber) {
...
}
Run Code Online (Sandbox Code Playgroud)