开发者社区> 问答> 正文

如何显示WPF绑定的选定项目

C#:

public void SetCompetition(Window wT1)
{
    //Add all the Copetition
    wT1._competition = new List<Competition>();
    wT1._competition.Add(new Competition { Logo = "3.png", Name = "test1", IsSelected = false });
    wT1._competition.Add(new Competition { Logo = "3.png", Name = "test2", IsSelected = false });
    wT1._competition.Add(new Competition { Logo = "3.png", Name = "test3", IsSelected = false });
    wT1._competition.Add(new Competition { Logo = "3.png", Name = "test4", IsSelected = false });

        wT1.cboSetupCompetition.ItemsSource = wT1._competition;
        wT1.cboSetupCompetition.Items.Refresh();
    }

展开
收起
游客ufivfoddcd53c 2020-01-04 10:58:12 917 0
1 条回答
写回答
取消 提交回答
  • 设置to 的IsEditable属性,它应该可以正常工作,即在关闭时,您将应用于所选项目:ComboBoxfalseDataTemplateComboBox

    <ComboBox x:Name="cboSetupCompetition" IsEditable="False"  ItemTemplate="{DynamicResource cmbCompetition}" HorizontalAlignment="Left" Margin="29,28,0,0" VerticalAlignment="Top" Width="173" RenderTransformOrigin="0.5,0.591" FontSize="12" Height="22" Background="#FFD8D8D8" SelectionChanged="UpdateCompetitionSelection"/>
    
    2020-01-04 10:59:11
    赞同 展开评论 打赏
问答分类:
C#
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载