Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextBox "Auto" Watermark-text #2712

Closed
kamilkosek opened this issue Oct 24, 2016 · 3 comments · Fixed by #2722
Closed

TextBox "Auto" Watermark-text #2712

kamilkosek opened this issue Oct 24, 2016 · 3 comments · Fixed by #2722
Milestone

Comments

@kamilkosek
Copy link

kamilkosek commented Oct 24, 2016

What steps will reproduce this issue?

Not a real issue but a question.
Would it be possible to automatically set the watermark text to the bound property name ?
Or even better, take automatically the value of the Display-Attribute from the property as the Watermark text.
Lets say I got this Model

public class Device
    {
        [Display(Name = "Geräte Id")]
        public int DeviceId { get; set; }
        [Display(Name = "Geräte Name")]
        public string DeviceName { get; set; }
    }

and on the textbox looks e.g. like this

<StackPanel DataContext="{Binding MyDevice}">
                    <TextBox mah:TextBoxHelper.AutoWatermark="True" Text="{Binding DeviceId}"></TextBox>
                </StackPanel>

All the best,
Kamil

@punker76
Copy link
Member

@kamilkosek I think that's not so easy. Cause for this it's necessary to look at the binded property for the DisplayAttribute. I don't know yet how we can do this in an easy way.
/cc @thoemmi

@michaelmairegger
Copy link
Contributor

michaelmairegger commented Oct 29, 2016

@punker76 Yes it is possible and easy to implement. I am working on a PR. But the requested feature is NET45 only, as the required methods are >= 4.5

@punker76
Copy link
Member

@xxMUROxx Getting the DisplayAttrubute and Binding should be also available in .Net 4, or not? What restriction is it?

michaelmairegger added a commit to michaelmairegger/MahApps.Metro that referenced this issue Oct 29, 2016
This commit introduces the possibility to retrieve the automark text directly from the property that is used for data binding
@punker76 punker76 added this to the 1.4.0 milestone Nov 18, 2016
punker76 pushed a commit that referenced this issue Nov 19, 2016
* [Introducing] AutoWatermark #2712

This commit introduces the possibility to retrieve the automark text directly from the property that is used for data binding

* Add property mapping for controls

* Add AttachedPropertyBrowsableForType-Attribute

* Add WatermarkAttribute

* Add NET4_5 compiler switch

* Add example to DateExamples.xaml

* Add code to support auto-watermark on <NET4.5 too

* Use DisplayAttribute instead of WatermarkAttribute

* Use GetDescription instead of Description to support localizable strings

* Revert XAML-Style changes introduced by mistake

* Code cleanup

* Add Dependency Property documentation

* Subscribe to event only in case of Autowatermark is true.
If control is already loaded, directly call the method for retrieving the information.
If deactivated unsubscribe from event.

* [Fix] Issue with DOT-binding
e.g. "{Binding Property.OtherProperty}"

* [Fix] Issue when using Array Indexer as binding path
e.g. PropertyWithCollection[0]. This is not supported

* [Fix] Issue whith using . Paths in NET4

* Allow binding to element of collection

* Allow Write-Only Properties too.

* Extracted Methods for better understanding

* Adding XML-Documentation

* Use Display.Prompt intead of Display.Description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants