tags:

views:

205

answers:

3

Hi,

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

A: 

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...

HTH, Kent

Kent Boogaart
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...
caiokf
in that case, can you post a full repro that doesn't require external libraries?
Kent Boogaart
A: 

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 ?

ExistMe
actually doesn't have to be propertygrid, I tested with other controls, and the UI doesn't want to update. tried UpdateLayout(), also did not work. thanks
caiokf
A: 
stackPanel.InvalidateVisual();

Please add this at the last line.

Akash Kava