0

I'm trying to update some user control in wpf by code, with no luck.

That's the xaml:

<UserControl x:Class="SimuladorNocs.UI.Diagram.PropertiesWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:PropertyGrid="clr-namespace:Deepforest.WPF.Controls"
>
<DockPanel>        
    <StackPanel x:Name="stackPanel" Width="300" Height="600" HorizontalAlignment="Center">

        <PropertyGrid:PropertyGridControl Height="300"  x:Name="MyPropertyGrid" />

    </StackPanel>     
</DockPanel>

and that's the c# code:

public void SetInstance(object obj){
    MyPropertyGrid = new PropertyGridControl { Instance = obj, Height = 300 };
    stackPanel.Children.Clear();
    stackPanel.Children.Add(MyPropertyGrid);    }

In the end, the property appers to be changing, but I was unable to see the changes in the UI. I also tried to create a new object instead of using the existing MyPropertyGrid, did not work, also tried not clearing the stackpanel without success...

What am I missing?

Thanks

3 Answers 3

2
stackPanel.InvalidateVisual();

Please add this at the last line.

Sign up to request clarification or add additional context in comments.

Comments

1

I don't have the specified propertygrid control but it seems that the UI doesn't get updated. did you try "UpdateLayout()" on that control and on the stack panel itself ?

Comments

0

Swapped out the PropertyGridControl for a Label and it worked fine. I suggest you do the same. If it works, it's more a question of what the PropertyGridControl is doing wrong...

2 Comments

no, it did not work for me. try to do that, but make the call to SetInstance() from another usercontrol, when you call from the constructor for example, it works...
in that case, can you post a full repro that doesn't require external libraries?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.