Label doesn't display “_” character

前端 未结 7 1844
别跟我提以往
别跟我提以往 2021-01-01 09:10

My Label.Content in WPF doesn\'t display the first occurrence of \"_\" character. Why?



        
7条回答
  •  萌比男神i
    2021-01-01 09:13

    Use of TextBlock to solve this issue comes with some disadvantages, such as the inability to center the content vertically (save for placing it within a grid, and there are many situations where the requisite additional controls may be undesirable). In my case, I created a TextBox that behaves like a Label using the following code:

    var fauxLabel = new TextBox();
    fauxLabel.Cursor = Cursors.Arrow; // Avoid the IBeam mouse cursor when hovering
    fauxLabel.Background = Brushes.Transparent;
    fauxLabel.BorderThickness = new Thickness(0.0, 0.0, 0.0, 0.0);
    fauxLabel.Focusable = false;
    

提交回复
热议问题