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

Comments

Projects
None yet
3 participants
@kamilkosek

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

This comment has been minimized.

Show comment
Hide comment
@punker76

punker76 Oct 28, 2016

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

Member

punker76 commented Oct 28, 2016

@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

@xxMUROxx

This comment has been minimized.

Show comment
Hide comment
@xxMUROxx

xxMUROxx Oct 29, 2016

Contributor

@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

Contributor

xxMUROxx 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

This comment has been minimized.

Show comment
Hide comment
@punker76

punker76 Oct 29, 2016

Member

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

Member

punker76 commented Oct 29, 2016

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

xxMUROxx added a commit to xxMUROxx/MahApps.Metro that referenced this issue Oct 29, 2016

[Introducing] AutoWatermark #2712
This commit introduces the possibility to retrieve the automark text directly from the property that is used for data binding

@xxMUROxx xxMUROxx referenced this issue Oct 29, 2016

Merged

Feature/auto watermark #2722

4 of 4 tasks complete

@punker76 punker76 added this to the 1.4.0 milestone Nov 18, 2016

@punker76 punker76 closed this in #2722 Nov 19, 2016

punker76 added a commit that referenced this issue Nov 19, 2016

Feature/auto watermark (#2722)
* [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