想用WPF做一个类似QQ登入窗口记住密码下拉框combobox的效果,里面有账号和关闭按钮图标 5
这是我的xaml代码,<StackPanelMargin="10,80,10,10"><ComboBoxName="cmbTest"><ComboBoxItem><Sta...
这是我的xaml代码,
<StackPanel Margin="10,80,10,10">
<ComboBox Name="cmbTest">
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBox Name="cmbContent" Text="{Binding stuName}"></TextBox>
<Button Name="cmbClose" Content="CLOSE">
<Button.Background>
<ImageBrush ImageSource="/WpfApplication2;Component/Resources/Close.png" Stretch="Fill" />
</Button.Background>
</Button>
</StackPanel>
</ComboBoxItem>
</ComboBox>
</StackPanel>
------------------------------------------------------------------------------
想把cmbContent绑定到一个ObserveColliction的数据源中,代码在初始化构造函数中
ObservableCollection<Student> dataMenber = new ObservableCollection<Student>();
Student student1 = new Student();
student1.name = "Ling";
student1.id = "00584";
student1.score = 90;
Student student2 = new Student();
。。。
Student student4 = new Student();
dataMenber.Add(student1);
dataMenber.Add(student2);
dataMenber.Add(student3);
dataMenber.Add(student4);
cmbContent.DataContext = dataMenber;
------------------------------------------------------------------------------
其中Student类有stuName字段,但是运行之后点击combox下拉框只能显示第一条数据(Ling),应该有4条才对啊,求问大神为什么 展开
<StackPanel Margin="10,80,10,10">
<ComboBox Name="cmbTest">
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBox Name="cmbContent" Text="{Binding stuName}"></TextBox>
<Button Name="cmbClose" Content="CLOSE">
<Button.Background>
<ImageBrush ImageSource="/WpfApplication2;Component/Resources/Close.png" Stretch="Fill" />
</Button.Background>
</Button>
</StackPanel>
</ComboBoxItem>
</ComboBox>
</StackPanel>
------------------------------------------------------------------------------
想把cmbContent绑定到一个ObserveColliction的数据源中,代码在初始化构造函数中
ObservableCollection<Student> dataMenber = new ObservableCollection<Student>();
Student student1 = new Student();
student1.name = "Ling";
student1.id = "00584";
student1.score = 90;
Student student2 = new Student();
。。。
Student student4 = new Student();
dataMenber.Add(student1);
dataMenber.Add(student2);
dataMenber.Add(student3);
dataMenber.Add(student4);
cmbContent.DataContext = dataMenber;
------------------------------------------------------------------------------
其中Student类有stuName字段,但是运行之后点击combox下拉框只能显示第一条数据(Ling),应该有4条才对啊,求问大神为什么 展开
展开全部
Event Form1.Load
Form1.Timer1.Enabled = True //默认定时器是启动状态,所以要先停止
Form1.Timer1.Interval = 1 //设置定时器循环的间隔时间(单位:毫秒)
End Event
Event Form1.Timer1.Timer
Key=GetLastKey()
// 112 = F1
If Key = 112 Then
Form1.ComboBox1.ListIndex = 0
ElseIf Key = 113 Then
Form1.ComboBox1.ListIndex = 1
ElseIf Key = 114 Then
Form1.ComboBox1.ListIndex = 2
ElseIf Key = 115 Then
Form1.ComboBox1.ListIndex = 3
ElseIf Key = 116 Then
Form1.ComboBox1.ListIndex = 4
ElseIf Key = 117 Then
Form1.ComboBox1.ListIndex = 5
ElseIf Key = 118 Then
Form1.ComboBox1.ListIndex = 6
End If
End Event
Form1.Timer1.Enabled = True //默认定时器是启动状态,所以要先停止
Form1.Timer1.Interval = 1 //设置定时器循环的间隔时间(单位:毫秒)
End Event
Event Form1.Timer1.Timer
Key=GetLastKey()
// 112 = F1
If Key = 112 Then
Form1.ComboBox1.ListIndex = 0
ElseIf Key = 113 Then
Form1.ComboBox1.ListIndex = 1
ElseIf Key = 114 Then
Form1.ComboBox1.ListIndex = 2
ElseIf Key = 115 Then
Form1.ComboBox1.ListIndex = 3
ElseIf Key = 116 Then
Form1.ComboBox1.ListIndex = 4
ElseIf Key = 117 Then
Form1.ComboBox1.ListIndex = 5
ElseIf Key = 118 Then
Form1.ComboBox1.ListIndex = 6
End If
End Event
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这是我的xaml代码,
<StackPanel Margin="10,80,10,10">
<ComboBox Name="cmbTest">
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBox Name="cmbContent" Text="{Binding stuName}"></TextBox>
<Button Name="cmbClose" Content="CLOSE">
<Button.Background>
<ImageBrush ImageSource="/WpfApplication2;Component/Resources/Close.png" Stretch="Fill" />
</Button.Background>
</Button>
</StackPanel>
</ComboBoxItem>
</ComboBox>
</StackPanel>
------------------------------------------------------------------------------
想把cmbContent绑定到一个ObserveColliction的数据源中,代码在初始化构造函数中
ObservableCollection<Student> dataMenber = new ObservableCollection<Student>();
Student student1 = new Student();
student1.name = "Ling";
student1.id = "00584";
student1.score = 90;
Student student2 = new Student();
。。。
Student student4 = new Student();
dataMenber.Add(student1);
dataMenber.Add(student2);
dataMenber.Add(student3);
dataMenber.Add(student4);
cmbContent.DataContext = dataMenber;
------------------------------------------------------------------------------
其中Student类有stuName字段,但是运行之后点击combox下拉框只能显示第一条数据(Ling),应该有4条才对啊,求问大神为什么
<StackPanel Margin="10,80,10,10">
<ComboBox Name="cmbTest">
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBox Name="cmbContent" Text="{Binding stuName}"></TextBox>
<Button Name="cmbClose" Content="CLOSE">
<Button.Background>
<ImageBrush ImageSource="/WpfApplication2;Component/Resources/Close.png" Stretch="Fill" />
</Button.Background>
</Button>
</StackPanel>
</ComboBoxItem>
</ComboBox>
</StackPanel>
------------------------------------------------------------------------------
想把cmbContent绑定到一个ObserveColliction的数据源中,代码在初始化构造函数中
ObservableCollection<Student> dataMenber = new ObservableCollection<Student>();
Student student1 = new Student();
student1.name = "Ling";
student1.id = "00584";
student1.score = 90;
Student student2 = new Student();
。。。
Student student4 = new Student();
dataMenber.Add(student1);
dataMenber.Add(student2);
dataMenber.Add(student3);
dataMenber.Add(student4);
cmbContent.DataContext = dataMenber;
------------------------------------------------------------------------------
其中Student类有stuName字段,但是运行之后点击combox下拉框只能显示第一条数据(Ling),应该有4条才对啊,求问大神为什么
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我运行看到的是一条都没有,下拉只看到一个Closebutton。
你的Xaml写法表明你对ComboBox的概念很模糊,再说要提问的话最好精简再精简,提炼出本质,本来你这提问是百度知道上少数的规范问题了,但太多琐碎细节让回答者无法给你简单的答案。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询