Rehosted WF4.0 designer does not update activity from canvas when the designer.Text (xaml ) modified xaml

165 Views Asked by At

I have created rehosted designer studio like Visual Studio IDE. What I want to achieve, When I will modify xaml from xamlTextEditor (My costume text box) designer from center canvas should update/refresh.

designer.Xaml code

<TabControl HorizontalAlignment="Stretch" 
                VerticalAlignment="Stretch" 
                Grid.Column="1" Grid.RowSpan="2" Margin="0,22,0,5" >
        <TabItem Header="Designer">
            <ContentControl Content="{Binding WorkflowDesignerControl}" Margin="0,0,0,0"/>
        </TabItem>
        <TabItem Header="XAML" 
                 GotFocus="RefreshXamlTabOnTabItemFocus" >
            <TextBox Name="xamlTabTextBox" Text="{Binding XAML, Mode=OneWay}"
                     AcceptsReturn="True" TextChanged="XamlTextView_TextChanged"
                     HorizontalScrollBarVisibility="Auto"
                     VerticalScrollBarVisibility="Auto" IsReadOnly="False">
            </TextBox>
        </TabItem>
    </TabControl>

designer.xaml.cs i have property to get xaml text

public string XAML
    {
        get
        {
            if (this.workflowDesigner.Text != null)
            {
                this.workflowDesigner.Flush();
                return this.workflowDesigner.Text;
            }

            return null;
        }
    }

I have RefreshXamlTabOnTabItemFocus

private void RefreshXamlTabOnTabItemFocus(object sender, RoutedEventArgs e)
    {
        this.designerViewModel.NotifyChanged("XAML");
    }

Text change event

private void XamlTextView_TextChanged(object sender, EventArgs e)
    {
        this.workflowDesigner.Flush();
        XDocument xd = XDocument.Parse(this.xamlTextView.Text);
        this.workflowDesigner.Text = xd.ToString();
        this.workflowDesigner.View.UpdateLayout();
    }

enter image description here

You can see I have only one activity in Main sequence. my scenario is like

  1. I have updated Assign display name from designer then it will reflect in XAML text view.
  2. When I am modifying same display name from textbox (XAML) it's not reflecting in designer.

any one can suggest me the possible solution so I can you designer text in TwoWay?

thank you in advance.

0

There are 0 best solutions below