wpf - Which combination of controls can we use for indicating a mandatory field? -


i have figured out 3 different ways represent mandatory field label. not sure use ideal. 1 requirement label should support access keys. please me understand of them should used. alternative suggestions appreciated.

<label width="200" horizontalalignment="left" target="{binding elementname=mytb}">     <textblock>         <run text="*" foreground="red" fontweight="heavy" />         <accesstext text="_name"/>     </textblock> </label>  <label verticalalignment="center" horizontalalignment="center" target="{binding elementname=mytb}">     <stackpanel orientation="horizontal" grid.row="17" grid.column="0" horizontalalignment="right">         <textblock text="*" foreground="red" verticalalignment="center" fontweight="heavy"></textblock>         <accesstext text="_name:" />     </stackpanel> </label>  <stackpanel orientation="horizontal">     <textblock text="*" foreground="red" verticalalignment="center" fontweight="heavy"/>     <label content="_name" verticalalignment="center" target="{binding elementname=mytb}"/> </stackpanel> 

if had choose 1 of examples, choose first, if not, use attached property instead:

<textbox text="{binding someproperty}" attached:textboxproperties.ismandatory="true" /> 

of course, have small problem of creating attached property, red asterisks (*) so last era. ismandatory property displays message in textbox when empty, wpf... yours add red asterisk or else can imagine. use attached property add asterisk onto label instead of textbox in example.

my attached property works in conjunction label , labelcolour attached properties each add functionality... label property provides simple controltemplate (which default textbox template textblock) reads app.xaml page. labelcolour property lets me select different foreground colours textblock, internally set red when using ismandatory property.

my point this: could go old red asterisk many before you, or could branch out , utilise features wpf provides come better solution.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -