UWP。如何在UWP中以列表框粗体显示一些项目。 [英] UWP. How to do some items in listbox bold in UWP.

查看:125
本文介绍了UWP。如何在UWP中以列表框粗体显示一些项目。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在UWP C#的列表框中使一些项目变为粗体?



我尝试了什么:



How can make some items bold in listbox on UWP C#?

What I have tried:

Google shows a lot of links how to make some items in listbox(listview) bold.
But there no result with UWP. WPF APIs do not work in UWP.

推荐答案

WPF API在UWP中不起作用



WPF APIs don't work in UWP

public Form1()
    {
        InitializeComponent();

        ListBox1.Items.AddRange(new Object[] { "First Item", "Second Item"});
        ListBox1.DrawMode = DrawMode.OwnerDrawFixed;
    }

    private void ListBox1_DrawItem(object sender, DrawItemEventArgs e)
    {
        e.DrawBackground();
        e.Graphics.DrawString(ListBox1.Items[e.Index].ToString(), new Font("Arial", 10, FontStyle.Bold), Brushes.Black, e.Bounds);
        e.DrawFocusRectangle();
    }


这篇关于UWP。如何在UWP中以列表框粗体显示一些项目。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆