Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF - Dependency Properties Error
    text
    copied!<p>I'm working on a WPF project, and my intention is to make two specific RadioButtons alter properties of another specified Component. But for now, i'm just trying to store a String inside the RadioButton.</p> <p>For that, I've created a behavior class: </p> <pre><code> public class AdjustBehavior : Behavior&lt;RadioButton&gt; { </code></pre> <p>With this property:</p> <pre><code> public static DependencyProperty AdjustLabelContentProperty = DependencyProperty.RegisterAttached("LabelContent", typeof(String), typeof(AdjustBehavior), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits)); </code></pre> <p>And these getters and setters:</p> <pre><code> public static String GetLabelContent(RadioButton tb) { return (String)tb.GetValue(AdjustLabelContentProperty); } public static void SetLabelContent(RadioButton tb, String value) { tb.SetValue(AdjustLabelContentProperty, value); } </code></pre> <p>On the XAML side, I did this:</p> <pre><code> &lt;RadioButton Content="Banana" Height="16" HorizontalAlignment="Left" Margin="30,216,0,0" Name="radioButton1" VerticalAlignment="Top" GroupName="a" IsThreeState="False" IsChecked="True" Checked="radioButton1_Checked" &gt; &lt;int:Interaction.Behaviors&gt; &lt;i:AdjustBehavior LabelContent="Apple" /&gt; &lt;/int:Interaction.Behaviors&gt; &lt;/RadioButton&gt; </code></pre> <p>Where int: is the namespace to Interaction.Behaviors and i: is the namespace to the AdjustBehavior class. But whenever I start my application, LabelContent is set to null. Why?</p> <p>I didn't post the rest of my Behavior class because I think it won't matter, but I'll do if necessary.</p> <p>Thanks in Advance.</p> <p>Clark</p>
 

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