嘿我怎样才能检测到我的ListView向上或向下滚动?
我有这个:
private void MainPage_OnLoaded(object sender, RoutedEventArgs e)
{
var scrollViewer = MyListView.GetFirstDescendantOfType<ScrollViewer>();
scrollViewer.ViewChanged += BarScroll;
}
private void BarScroll(object sender, ScrollViewerViewChangedEventArgs e)
{
var scrollbars = (sender as ScrollViewer).GetDescendantsOfType<ScrollBar>().ToList();
var verticalBar = scrollbars.FirstOrDefault(x => x.Orientation == Orientation.Vertical);
if (verticalBar) (/*If ListView is scrolled up*/)
{
//Code when the ListView is scrolled up
}
else (/*If ListView is scrolled down*/)
{
//Code for when the ListView is scrolled down
}
}
Run Code Online (Sandbox Code Playgroud)
我需要对"verticalBar.Height> verticalBar.ActualHeight"做些什么吗?
我试图在上传excel文件后将第18列,Test的值变为大写但没有任何成功.

我怎样才能达到DataTable中的值?
这是我用excel文件中的值填充DataTable的地方:
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
return dataTable;
}
Run Code Online (Sandbox Code Playgroud)
我希望18中的所有值都是大写的.
有一些示例可以执行此操作,但它们适用于Windows Phone 8.0或8.1 Silverlight.
但是如何为Windows Phone 8.1 Runtime执行此操作?
当值为空时,我可以将 TextBox 设为红色,但只有在我单击按钮之后。但是如何在不单击按钮的情况下使其为空时变为红色?
我正在使用 MVVM Light,它与“TwoWay”有关吗?或者 RaisePropertyChanged 或 OnpropertyChanged?
这是我的 xaml 中的一个 TextBox:
<TextBox Text="{Binding SelectedPerson.FirstName, Mode=TwoWay}"
Width="200"
HorizontalAlignment="Left"
Background="Grey"
Foreground="White"
BorderThickness="1"
BorderBrush="{Binding Color, Mode=TwoWay}" />
Run Code Online (Sandbox Code Playgroud)
这是我的 ViewModel 上的代码:
private SolidColorBrush _Color;
public SolidColorBrush Color
{
get
{
return _Color;
}
set
{
_Color = value;
RaisePropertyChanged("Color");
}
}
Run Code Online (Sandbox Code Playgroud)
然后这是按钮命令:
public RelayCommand UpdatePerson
{
get
{
return new RelayCommand(async () =>
{
Color = new SolidColorBrush(Colors.Red);
//....
});
}
}
Run Code Online (Sandbox Code Playgroud)
所以我想要的是,当 FirstName TextBox 为空时,边框变为红色,无需单击按钮。
private Person _SelectedPerson;
public Person SelectedPerson …Run Code Online (Sandbox Code Playgroud) 我有这个简单的JSON
{
"persons": [{
"firstname": "Brad",
"lastname": "Pitt"
}, {
"firstname": "George",
"lastname": "Clooney"
}, {
"firstname": "Matt",
"lastname": "Damon"
}]
}
Run Code Online (Sandbox Code Playgroud)
这是我在C#中的课程:
public class PersonObject
{
[JsonProperty(PropertyName = "persons")]
public List<Person> Persons { get; set; }
}
public class Person
{
[JsonProperty(PropertyName = "firstname")]
public string Firstname { get; set; }
[JsonProperty(PropertyName = "lastname")]
public string Lastname { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因它总是返回null ...我真的看不出这有JsonConvert.DeserializeObject什么问题...因为它没有错,因为它适用于其他JSON字符串.
_PersonsList = JsonConvert.DeserializeObject<List<PersonObject>>(data);
Run Code Online (Sandbox Code Playgroud) c# ×6
bitmapimage ×1
bytearray ×1
data-binding ×1
eventargs ×1
excel ×1
json ×1
json.net ×1
listview ×1
mvvm-light ×1
scrollbar ×1
xaml ×1