0

There is a DockPanel and when I exercise this code it adds the dock content to the right Dock BUT I can't get it to show the text (i.e. Perform Step1 and Step2 etc. as seen below). I have done so much research, nothing has worked. Thanks in advance for your help.

public void ShowInstructionForm()
{
    dragDropForm = new DockContent();
    dragDropForm.Name = "Hints";

    dragDropForm.TabText = "Hints2";
    dragDropForm.ShowHint = DockState.DockRight;
    dragDropForm.BackColor = Color.White;
    dragDropForm.Text = "- Perform the step number 1 ."
        + Environment.NewLine + " - Perform the Step number 2";                                     

    try
    {
        dragDropForm.Show(this.oDock.MainDock);
    }
    catch (Exception e)
    {
        MessageBox.Show(this.oDock.MainDock, "error happened  " + e.Message);
    }
}
Ian R. O'Brien
  • 6,682
  • 9
  • 45
  • 73
user1298925
  • 2,304
  • 7
  • 29
  • 43

2 Answers2

1

Personally I would use data binding to achieve what it is you want so that you are adhering to a more rigid design pattern.

XAML

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <DockPanel>
        <TextBlock Text="{Binding Path=Foo}" />
    </DockPanel>
</Window>

C#

public partial class MainWindow : Window
{
    public string Foo { get; set; }

    public MainWindow()
    {
        Foo = "hello world"; // Changing Foo 'automagically' changes your textblock value
        InitializeComponent();
    }
}

This allows you to be more flexible by having your business logic separated from your UI code. Obviously this is just an example of data binding with a text block inside a dock panel but hopefully this gives you a better understanding.

ed_me
  • 3,338
  • 2
  • 24
  • 34
0

Can you go into xaml and place a textblock in in the DockPanel like this:

<DockPanel>
  <TextBlock Text="- Perform the step number 1 ."/>
</DockPanel>
DJ Burb
  • 2,346
  • 2
  • 29
  • 38