Conditional フォーマッター
条件付き書式設定 (Conditional formatting) は、コロン (:) の後にバーティカルバー (|) が含まれたプレースホルダーで発生します。 Conditional Formatter を明示的に呼び出すには、"conditional" あるいは "cond" という名前を使用してください。また、名前が指定されていない時に暗黙的に使用することも可能です。
| データ型 | 構文 | 例 |
|---|---|---|
| 数値 (整数、ダブルなど) | {0:one|default} | {0} {0:item|items} |
| {0} {0:item|items} | {0:no items|one item|many items} | |
| {0:negative|zero|one|default} | {0:negative items|no items|one item|many items} | |
| ブール | {0:true|false} | Enabled? {0:Yes|No} |
| 文字列 | {0:default|null or empty} | Text: {0:{0}|No text to display} |
| DateTime | {0:before|after} (as compared to Date.Now) | My birthday {0:was on|will be on} {0:MMMM d} |
| TimeSpan | {0:negative|positive} | My birthday {0:was {0} ago|will be in {0} from now} |
| {0:negative|zero|positive} | My birthday {0:was {0} ago|is today!|will be in {0} from now} | |
| オブジェクト | {0:default|nothing} | Property: {0:{0}|(Nothing)} |
各パラメーターは "|" で区切られます。比較の後には "?" が続き、その後ろにテキストが続きます。最後の (デフォルトの) エントリーには比較も "?" も含まれません。
以下の比較がサポートされています。
- >=
- >
- =
- <
- <=
- !=
比較を組み合わせる場合、AND には "&"、OR には "/" を使用してください。
| Smart String の例 | 引数 | 結果 |
|---|---|---|
| {0:cond:>10?Greater Than 10|=10?Equals to 10|Less than 10} | 5 |
Less than 10 |
| {Age:cond:>=55?Senior Citizen|>=30?Adult|>=18?Young Adult|>12?Teenager|>2?Child|Baby} | |
Adult |