溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

WPF:DataGrid -- DataGridTextColumn文字居中顯示及選中時(shí)失去焦點(diǎn)時(shí)顏

發(fā)布時(shí)間:2020-09-06 18:36:30 來源:網(wǎng)絡(luò) 閱讀:3557 作者:006玩命 欄目:編程語言

簡(jiǎn)述

  DataGrid的Header風(fēng)格(按比例顯示列、居中顯示)已講解,但并不能使得DataGrid的內(nèi)容居中顯示。其他暫未用到,列使用DataGridTextColumn顯示文字時(shí),可添加表格元素風(fēng)格,設(shè)置文字居中顯示。
  列DataGridTextColumn被選中時(shí),若點(diǎn)擊其他地方,可自定義設(shè)置DataGrid的非活動(dòng)狀態(tài)顏色風(fēng)格。

代碼

  1. 文字居中顯示
    <!-- DataGridTextColumn 文字居中 -->
    <Style x:Key="CenterAlignmentStyle" TargetType="TextBlock">
        <Setter Property="TextAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

2、選中時(shí)失去活動(dòng)狀態(tài)顏色設(shè)置
WPF:DataGrid -- DataGridTextColumn文字居中顯示及選中時(shí)失去焦點(diǎn)時(shí)顏

效果

WPF:DataGrid -- DataGridTextColumn文字居中顯示及選中時(shí)失去焦點(diǎn)時(shí)顏

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI