Select to view content in your preferred language

Window Panel Problem

2880
4
05-17-2010 01:46 AM
AnilDhiman
Deactivated User
Arcgis silverlight template comes with a Window panel control. I have placed a user control which takes Map as dependency property. Now, I need this Window panel to collapse on Load. I tried Visibility=Collapsed in XAML and it worked  but now My dependency property is not firing.

Is this a bug with Window Panel? or is there any other method to do so
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
As your control is not visible, it's not loaded.
You might try by making it visible and by collapsing it when loaded.
Example in XAML:
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Loaded">
                    <ei:ChangePropertyAction PropertyName="Visibility">
                        <ei:ChangePropertyAction.Value>
                            <Visibility>Collapsed</Visibility>
                        </ei:ChangePropertyAction.Value>
                    </ei:ChangePropertyAction>
                </i:EventTrigger>
            </i:Interaction.Triggers>
0 Kudos
AnilDhiman
Deactivated User
I tried this but still depency property is not firing. any suggestions?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I did some additional tests and I was able to reproduce the issue when the DP is initialized with a binding. Is it your case?

In this case, the DP is initialized after the Loaded event (if the control is visible), and so if the loaded event put the visibility to collapsed, the DP is not initialized.
This behavior doesn't look tie to the Window Panel but more general to the Loaded event with Silverlight.

I found an article (http://bryantlikes.com/FakingTheInitializedEventInSilverlight.aspx) which is suggesting to use the dispatcher in the constructor.
If we change the visibility this way, the DP are initialized (in the cases I tested...)

public MainPage()
{
 InitializeComponent();
 Dispatcher.BeginInvoke(Initialized);
}

private void Initialized()
{
 MyControl.Visibility = Visibility.Collapsed;
}


Note that another workaround could be you to change the Opacity instead of the Visibility. Keep your control visible but with an opacity of 0. So the DP are initialized and when your control is ready, you can set the opacity to 1.0.
0 Kudos
AnilDhiman
Deactivated User
Thanks for your suggestions, I did a similar workaround by changing the margin of control to out of screen and on click of button again changed the margin as desired.

but the first approach looks pretty good. I will try that, thanks
0 Kudos