Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF - Binding in simple User Control
    primarykey
    data
    text
    <p>My problem is certainly right on my face but I can't see it...</p> <p>I am building a very simple user control - a 3D ellipse - and I expose two properties: LightColor and DarkColor. I need to bind these properties to the gradient in my user control, but it is not showing any color at all. Here's my usercontrol:</p> <pre><code>&lt;UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TestBrushes" mc:Ignorable="d" x:Class="TestBrushes._3DEllipse" x:Name="UserControl" d:DesignWidth="200" d:DesignHeight="200"&gt; &lt;Grid x:Name="LayoutRoot"&gt; &lt;Ellipse Name="MainEllipse" Stroke="{x:Null}"&gt; &lt;Ellipse.Fill&gt; &lt;RadialGradientBrush GradientOrigin="0.5,1.1"&gt; &lt;GradientStop Color="{Binding ElementName=UserControl, Path=LightColor}" Offset="1"/&gt; &lt;GradientStop Color="{Binding ElementName=UserControl, Path=DarkColor}" Offset="0"/&gt; &lt;/RadialGradientBrush&gt; &lt;/Ellipse.Fill&gt; &lt;/Ellipse&gt; &lt;Ellipse Name="TopReflectionEllipse" Stroke="{x:Null}" Margin="38,0,38,0" VerticalAlignment="Top" Height="90"&gt; &lt;Ellipse.Fill&gt; &lt;RadialGradientBrush GradientOrigin="0.5,0"&gt; &lt;RadialGradientBrush.RelativeTransform&gt; &lt;TransformGroup&gt; &lt;ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1" ScaleY="1"/&gt; &lt;SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/&gt; &lt;RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/&gt; &lt;TranslateTransform X="0" Y="0"/&gt; &lt;/TransformGroup&gt; &lt;/RadialGradientBrush.RelativeTransform&gt; &lt;GradientStop Color="#A5FFFFFF" Offset="0"/&gt; &lt;GradientStop Color="#00FFFFFF" Offset="1"/&gt; &lt;/RadialGradientBrush&gt; &lt;/Ellipse.Fill&gt; &lt;/Ellipse&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>and here's my code-behind:</p> <pre><code>public partial class _3DEllipse { public _3DEllipse() { InitializeComponent(); } public Color DarkColor { get; set; } public Color LightColor { get; set; } } </code></pre> <p>If I assign colors as opposed to the binding shown in the code, it works ok, but I want to use the properties I am exposing. What am I doing wrong?</p> <p>Thanks!</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.
 

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