Problem with initializewindow

Problem with initializewindow

Anonymous
Not applicable
309 Views
1 Reply
Message 1 of 2

Problem with initializewindow

Anonymous
Not applicable

Hello,

 

When I agree some code in the initializewindow from the "default.ps1" file, the "new standard folder" option dont works.

function InitializeWindow
{
	$dsWindow.Width = 700
	$dsWindow.Height = 550
  
$dsWindow.FindName("comboboxNum").SelectedIndex=0

}

-What is the problem?

-How can we initialize variables,combobox(with a specific index), call functions...etc from default.ps1 (InitializeWindow)?

 

 

Thank you very much,

Best regards.

 

Denis.

 

 

 

0 Likes
310 Views
1 Reply
Reply (1)
Message 2 of 2

marco.mirandola
Advocate
Advocate
Hi Deins, this goes in the right direction, but i would use another approach. Instead of working with the control it self, work with the bound property. You probably have a property bound to the SelectedValue of your combo, right?

Well then you can within the InitializeWindow use the $["PropName"].Value = "YourValue". This way the binding would do the rest. By setting the value to the property, the binding sets the SelectedValue accordingly.

Why does your code not work? I'm not sure as I didn't tried, but probably at the time when the window gets initialised the ItemsSource is not set, so the combobox is empty, so setting the index does not work. Just speculation.

Anyway, go by setting the Property instead of acting on the control. It's much safer and complain to the binding mechanics.

ciao
marco


coolOrange
www.coolorange.com
0 Likes