小编Bay*_*ern的帖子

检测ListView何时"向上"或"向下"滚动?Windows Phone 8.1 ListView

嘿我怎样才能检测到我的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"做些什么吗?

c# listview scrollbar windows-phone-8.1

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

从"System.EventArgs objArgs"中获取"Text"值

正如您在"objArgs"中的屏幕截图中所看到的,有一个属性"Text".我怎样才能到达那个房产?

在此输入图像描述

c# eventargs

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

如何将Excel中的列放入DataTable后以大写形式获取它们

我试图在上传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中的所有值都是大写的.

c# excel

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

在Windows Phone 8.1 Runtime中将BitmapImage转换为byte []数组

有一些示例可以执行此操作,但它们适用于Windows Phone 8.0或8.1 Silverlight.

但是如何为Windows Phone 8.1 Runtime执行此操作?

c# bytearray bitmapimage windows-runtime windows-phone-8.1

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

通过在 MVVM Light 中使用数据绑定,在值为空时使 TextBox 边框变为红色

当值为空时,我可以将 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)

c# data-binding xaml mvvm-light

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

JSON有效,但代码返回null

我有这个简单的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# json json.net

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