亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

WPF拖動(dòng)DataGrid滾動(dòng)條時(shí)內(nèi)容混亂的解決方法

 更新時(shí)間:2016年10月12日 10:31:44   作者:sunny906  
這篇文章主要介紹了WPF拖動(dòng)DataGrid滾動(dòng)條時(shí)內(nèi)容混亂的解決方法

在WPF中,如果DataGrid里使用了模板列,當(dāng)拖動(dòng)滾動(dòng)條時(shí),往往會(huì)出現(xiàn)列表內(nèi)容顯示混亂的情況。解決方法就是在Binding的時(shí)候給UpdateSourceTrigger賦值。

 <Grid>
  <Grid.RowDefinitions>
   <RowDefinition Height="25"></RowDefinition>
   <RowDefinition></RowDefinition>
  </Grid.RowDefinitions>
  <Button Height="23" Click="Button_Click" Content="Click" Grid.Row="0"></Button>
  <DataGrid Name="dgStudent" AutoGenerateColumns="False" IsEnabled="True" Grid.Row="1"
     EnableColumnVirtualization="True" EnableRowVirtualization="True">
   <DataGrid.Columns>
    <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="80"></DataGridTextColumn>
    <DataGridTemplateColumn Header="Age" Width="70">
     <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
       <TextBox Margin="5" Text="{Binding Age, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>
      </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    <DataGridTemplateColumn Header="Course" Width="100">
     <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
       <ComboBox Margin="5" ItemsSource="{Binding CourseSource}" Text="{Binding Course, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></ComboBox>
      </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
   </DataGrid.Columns>
  </DataGrid>
 </Grid>

后臺(tái)代碼如下:

 public class Student
 {
  public string Name { get; set; }
  public string Age { get; set; }
  public List<string> CourseSource { get; set; } = new List<string>() { "C", "C++", "C#" };
  public string Course { get; set; }
 }

 private void Button_Click(object sender, RoutedEventArgs e)
  {
   var students = new List<Student>();
   for (int i = 1; i <= 50; i++)
   {
    var student = new Student()
    {
     Name = $"student{i}"
    };
    students.Add(student);
   }
   this.dgStudent.ItemsSource = null;
   this.dgStudent.ItemsSource = students;
  }

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#操作PowerPoint的方法

    C#操作PowerPoint的方法

    這篇文章主要介紹了C#操作PowerPoint的方法,涉及C#針對(duì)PowerPoint的打開、讀取、播放等技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-04-04
  • 遞歸案例分享

    遞歸案例分享

    一般定義:程序調(diào)用自身的編程技巧稱為遞歸( recursion)。
    2014-05-05
  • 詳解C#中Dictionary<TKey,TValue>的存儲(chǔ)結(jié)構(gòu)

    詳解C#中Dictionary<TKey,TValue>的存儲(chǔ)結(jié)構(gòu)

    無論是實(shí)際的項(xiàng)目中,還是在我們學(xué)習(xí)的過程中,都會(huì)重點(diǎn)的應(yīng)用到Dictionary<TKey,?TValue>這個(gè)存儲(chǔ)類型,所以本文就來為大家介紹一下這一存儲(chǔ)結(jié)構(gòu)的相關(guān)知識(shí),希望對(duì)大家有所幫助
    2023-11-11
  • 使用Spire.Barcode程序庫生成二維碼的實(shí)例解析

    使用Spire.Barcode程序庫生成二維碼的實(shí)例解析

    這篇文章主要介紹了使用Spire.Barcode程序庫生成二維碼的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-12-12
  • C#中Response.Write常見問題匯總

    C#中Response.Write常見問題匯總

    這篇文章主要介紹了C#中Response.Write常見問題匯總,總結(jié)了C#中Response.Write的常用技巧,非常實(shí)用,需要的朋友可以參考下
    2014-09-09
  • 使用C#實(shí)現(xiàn)RTP數(shù)據(jù)包傳輸 參照RFC3550

    使用C#實(shí)現(xiàn)RTP數(shù)據(jù)包傳輸 參照RFC3550

    本篇文章小編為大家介紹,使用C#實(shí)現(xiàn)RTP數(shù)據(jù)包傳輸 參照RFC3550,需要的朋友參考下
    2013-04-04
  • C#?代碼大小寫規(guī)范說明

    C#?代碼大小寫規(guī)范說明

    這篇文章主要介紹了C#?代碼大小寫規(guī)范說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • C# 拷貝數(shù)組的幾種方法(總結(jié))

    C# 拷貝數(shù)組的幾種方法(總結(jié))

    下面小編就為大家?guī)硪黄狢# 拷貝數(shù)組的幾種方法(總結(jié))。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-08-08
  • C#?基于TCP?實(shí)現(xiàn)掃描指定ip端口的方式示例

    C#?基于TCP?實(shí)現(xiàn)掃描指定ip端口的方式示例

    本文主要介紹了C#基于TCP實(shí)現(xiàn)掃描指定ip端口的方式示例,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • c#?定期重啟程序操作的實(shí)現(xiàn)

    c#?定期重啟程序操作的實(shí)現(xiàn)

    本文主要介紹了c#?定期重啟程序操作的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-09-09

最新評(píng)論