title: Wpf Custom button icon and text change from code
body: <p>So I'm gonna be short. I would like to set the textBlock (x:Name="ButtonText") and Images (x:Name="LeftIcon" and x:Name="RightIcon") from code in another Project using the compiled .dll from this.</p>
  
  <p><strong>XAML:</strong></p>
  
  <pre><code>&lt;Button x:Class="myClass.actionButton"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     x:Name="ActionButton"&gt;
      &lt;Button.Template&gt;
          &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
              &lt;Border x:Name="button" CornerRadius="10" BorderBrush="#F555" BorderThickness="1.5"&gt;
                  &lt;Border.Background&gt;
                      &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                          &lt;GradientStop Color="#CC323232" Offset="0"/&gt;
                          &lt;GradientStop Color="#CC4B4B4B" Offset="1"/&gt;
                      &lt;/LinearGradientBrush&gt;
                  &lt;/Border.Background&gt;
              &lt;Grid&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="24"/&gt;
                      &lt;ColumnDefinition Width="1*"/&gt;
                      &lt;ColumnDefinition Width="24"/&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;TextBlock x:Name="ButtonText" Grid.Column="1" HorizontalAlignment="Center" TextWrapping="Wrap" Margin="0,0,0,0" VerticalAlignment="Center" Width="auto"/&gt;
                  &lt;Image x:Name="LeftIcon" Grid.Column="0" HorizontalAlignment="Left" Height="16" Margin="4,1,0,0" VerticalAlignment="Center" Width="16"/&gt;
                  &lt;Image x:Name="RightIcon" Grid.Column="2" HorizontalAlignment="Right" Height="16" Margin="0,1,4,0" VerticalAlignment="Center" Width="16"/&gt;
                  &lt;ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;/Grid&gt;
              &lt;/Border&gt;
          &lt;/ControlTemplate&gt;
      &lt;/Button.Template&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <p><strong>CS:</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using System.Windows.Markup;
  
  namespace myClass
  {
      public partial class actionButton : Button
      {
          private TextBlock ButtonText;
          private Image LeftIcon;
          private Image RightIcon;
  
          public Image leftIcon
          {
              get { return LeftIcon; }
              set { LeftIcon = value; }
          }
  
          public Image rightIcon
          {
              get { return RightIcon; }
              set { RightIcon = value; }
          }
  
          public TextBlock buttonText
          {
              get { return ButtonText; }
              set { ButtonText = value; }
          }
  
          public actionButton()
          {
              InitializeComponent();
          }
      }
  
  }
  </code></pre>
  
  <p>Currently if I append a new textBlock to my button instance from code, it doesn't show up... Same for the images. What am I missing?</p>
  
  <p>Thank you for the help... :)</p>