请教wpf下拉框类似QQ登录框,有做过的进!
有做过类似QQ登录框下拉框的样式,应该是一个combobox,下拉框每行有三列,图片,内容,删除按钮。
有做过的,请指教下,或者有例子可以参考的,先谢谢了。
[解决办法]
修改ComboBox ItemTemplate="{StaticResource LoginComboBoxData}"
<DataTemplate x:Key="LoginComboBoxData" DataType="LoginRecord">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding AvatarImageUrl}" />
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding UserName}" />
<TextBlock Text="{Binding UserAccount}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
this.ComboBox.ItemsSource=Data
[解决办法]
//这是那个imagebutton的点击事件
private void ImageButton_Click(object sender, RoutedEventArgs e)
{
Button b1 = sender as Button;
MessageBox.Show(b1.DataContext.ToString());//这样可以取到那个类study,但是我只想移除一条记录,cmb1.Items.Remove这边应该怎么写呢?
}
移除可以用两种方式
1.直接在点击事件中加一句
list1.remove(b1.DataContext as study)
然后重新绑定
cmb1.ItemsSource = list1;
这两句就ok
2.使用observablecollection<study> list
去绑定 然后只要从list里面执行
list.remove(b1.DataContext as study)
不需要重新绑定 前台会自动变
希望能帮到你 写的都是伪代码 具体对不对你自己敲下 然后点出来吧