Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't, this appears to be by design. While I can understand your approach to the mentioned book and am in no way questioning its quality, I'd still presume this to be some sort of copy&amp;paste or similar issue. Here is my reasoning:</p> <p><em>WPF property system code</em></p> <ul> <li>As you mentioned already the public API of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx" rel="nofollow noreferrer">DependencyProperty Class</a> only features <a href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.registerreadonly.aspx" rel="nofollow noreferrer">RegisterReadOnly()</a> and <a href="http://msdn.microsoft.com/en-us/library/ms597494.aspx" rel="nofollow noreferrer">RegisterAttachedReadOnly()</a>.</li> <li>Speluncing in the class internals via <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">Reflector</a> only reveals dedicated code for handling these <a href="http://msdn.microsoft.com/en-us/library/ms754044.aspx" rel="nofollow noreferrer">Read-Only Dependency Properties</a>, there is nothing in sight regarding write-only functionality.</li> <li>Another option might have been metadata, but neither <a href="http://msdn.microsoft.com/en-us/library/ms752375.aspx" rel="nofollow noreferrer">Dependency Property Metadata</a> nor in particular <a href="http://msdn.microsoft.com/en-us/library/ms751554.aspx" rel="nofollow noreferrer">Framework Property Metadata</a> by means of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkpropertymetadataoptions.aspx" rel="nofollow noreferrer">FrameworkPropertyMetadataOptions Enumeration</a> is providing anything along the lines of write-only.</li> </ul> <p><em>WPF property system design</em></p> <ul> <li>More important, <em>'The current WPF implementation of its XAML processor is inherently dependency property aware. The WPF XAML processor uses property system methods for dependency properties when loading binary XAML and processing attributes that are dependency properties. This effectively bypasses the property wrappers.'</em>, see <a href="http://msdn.microsoft.com/en-us/library/bb613563.aspx" rel="nofollow noreferrer">XAML Loading and Dependency Properties</a>.</li> <li>Most important, <em>'Dependency properties should generally be considered to be public properties. The nature of the Windows Presentation Foundation (WPF) property system prevents the ability to make security guarantees about a dependency property value.'</em>, see <a href="http://msdn.microsoft.com/en-us/library/ms752808.aspx" rel="nofollow noreferrer">Dependency Property Security</a>.</li> </ul> <p>Especially the latter two points are outlining the design constraint, that dependency property values are always accessible via <a href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyobject.getvalue.aspx" rel="nofollow noreferrer">GetValue()</a>/<a href="http://msdn.microsoft.com/en-us/library/ms597473.aspx" rel="nofollow noreferrer">SetValue()</a>, no matter whether their CLR wrappers are access restricted or available at all, with the only exception being the specifically accounted for <a href="http://msdn.microsoft.com/en-us/library/ms754044.aspx" rel="nofollow noreferrer">Read-Only Dependency Properties</a>.</p> <p>Consequently, as <a href="https://stackoverflow.com/questions/1315186/how-can-i-create-a-custom-write-only-dependency-property/1315209#1315209">Jeffs</a> answer implies already, just removing the getter for example does not really prevent anyone accessing the property via <a href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyobject.getvalue.aspx" rel="nofollow noreferrer">GetValue()</a>, though this may at least <em>'reduce the immediately exposed namespace of a custom class'</em>. The usefulness of any such semantic workaround of making the property value somewhat less visible/accessible and the retrieved value inherently useless for clients as suggested by <a href="https://stackoverflow.com/questions/1315186/how-can-i-create-a-custom-write-only-dependency-property/1315209#1315209">Jeff</a> depends on your particular scenario of course.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload