提案:使用 AttachedProperty 讓 IntelliSense 產生提示 #493
naukri7707
started this conversation in
Ideas
Replies: 1 comment
-
|
就像你说的,这样写会产生太多 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
簡介
由於現有的語法 IDE 無法在
axaml上產生 IntelliSense,如以下語法中Primary和OutlineButton無法被智能補全,因此我嘗試用 AttachedProperty 來解決這個問題。在使用 AttachedProperty 的語法中,輸入
semi:後就可以透過智能補全完成剩餘的內容。這可以減少設計時的心智負擔。同時能夠使用 Binding 處理一些複雜用例。
以及可以直接使用 C# 編寫
實作原理
具體實作方式是透過
AttachedProperty作為 Setter 去調整控件的Theme/Classes來完成的,所以除了計算外,應該不會產生什麼不良影響。我在此分支中有對
Button的具體實作和演示可以參考。主要困境
語法簡潔性
使用這種語法
axaml中會充斥著大量的semi:<Control>Style,雖然可以用XmlnsDefinition緩解一部分但此時需輸入完
ButtonStyle後才會產生提示,而且會破壞命名空間的定義。IDE 支援度
應該是 IDE 的問題,但這個語法目前只能在 Rider 中正常工作;使用 Visual Studio 時關鍵字 (
Primary、Outline) 不會被提示;VSCode 我的環境有點問題,無法使用 IntelliSense 所以不確定具體情況。Beta Was this translation helpful? Give feedback.
All reactions