我想实现在WPF中的ListView打开时就默认选中第一项并且模拟鼠标单击默认选中的那一项,我想请问一下这个该如何来实现呢?

解决方案 »

  1.   

    ListView.SelectedIndex=0;可能需要订阅 ContentLoaded 事件。
      

  2.   

    绑定ItemsSource到集合List<Model>,并且绑定SelecttedItem到对象SelectedModel,通过设置SelectedModel的值为List<Model>的某一项的值就可以设置选中项
      

  3.   


        <ComboBox Height="23" HorizontalAlignment="Left" Margin="246,118,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" SelectedIndex="0" >
                <ComboBoxItem Content="2" />
                <ComboBoxItem Content="1" />
            </ComboBox>
      

  4.   

    ListView.SelectedIndex=0;
    或者在xmal里面SelectedIndex=0
      

  5.   

    为什么说没有SelectedIndex这个属性呢?