實現乙個自動設外間距的Grid面板

2021-05-21 21:08:40 字數 993 閱讀 9204

緣起:經常用grid的做布局,感覺很好用.

但是當grid的行列數很多時,為了美觀,應讓其內部控制項有相應間距,不至於太擠. 

我們需要為其children設定margin屬性.

前面提到了grid的行列數很多,乙個個設定肯定不是乙個程式設計師喜歡的方式.當然有人提議用blend,雖然blend很好用,但是畢竟不是一勞永逸的方式,不喜歡.況且本人的電腦上也沒裝blend,而且不會用,o(∩_∩)o~

好了,上**:

using system.windows;

using system.windows.controls;

namespace customcontrollibrary

set

}// using a dependencyproperty as the backing store for cellmarginproperty.  this enables animation, styling, binding, etc...

public static readonly dependencyproperty cellmarginproperty =

dependencyproperty.register("cellmargin", typeof(thickness), typeof(automargingrid), new uipropertymetadata(new thickness(5,5,5,5)));

protected override size measureoverride(size constraint)

protected override system.windows.size arrangeoverride(system.windows.size arrangesize)

private void addmargintochild()}}

}xmal中**:

效果如圖:

圖1(標準grid控制項,未設定外間距)

圖2(automargingrid 自動設定外間距)

實現乙個簡單的服務自動重啟

今天跟大家分享乙個好用的技能 監聽檔案變化,自動重啟服務 很多時候我們都會用到webpack中帶的熱更新外掛程式來實現這個功能,接下來我們就來看下如何使用node原生的api來實現。此法不一定適用於所有專案 需要根據實際專案來自行選擇。首先我們來看下需要用到的 模組和api path child p...

用shell 實現自動ftp的乙個例項

bin bash echo echo cintel ftp test tool echo please input hostip c read hostip echo please input username c read username echo please input password c...

用SQL實現的乙個自動排課機制

同學畢業設計搞的是乙個排課系統,具體功能就給課程安排教室和時間。排課演算法是有一定難度的,很多老師說過,至今也沒有完美的排課演算法,的確,排課,是乙個五維交叉的複雜體系 時間 課程 教室 班級 學生。乙個排好的課表至少要保證以下幾點原則 乙個教師同一時間只上一門他要教的課 乙個班級同一時間只上一門他...