njsokalski
Well-known member
- Joined
- Mar 16, 2011
- Messages
- 102
- Programming Experience
- 5-10
I have the constructor for a UserControl for a Windows Phone 7 App:
You will notice that the only difference between the two for loops is that one uses White and one uses Black. However, the constructor is not working (my app will not start) with the code as is. My MainPage currently calls this constructor sending a value of False, and if I comment out the first For loop it will work. However, if I change the constructor to
Note that I used Not so that it goes to the first For loop instead, and commented out the second For loop, it does not work when I do this. But shouldn't it work either way, since the For loops are the only statements in the constructor and are (almost) exactly the same? Does the constructor have something against the color White? Any help would be appreciated. Thanks.
VB.NET:
Public Sub New(ByVal isodd As Boolean)
Me.New()
If (isodd) Then
For Each txt As UIElement In CType(Me.Content, StackPanel).Children
CType(txt, TextBox).BorderBrush = New SolidColorBrush(Colors.White)
Next
Else
For Each txt As UIElement In CType(Me.Content, StackPanel).Children
CType(txt, TextBox).BorderBrush = New SolidColorBrush(Colors.Black)
Next
End If
End Sub
VB.NET:
Public Sub New(ByVal isodd As Boolean)
Me.New()
If (Not isodd) Then
For Each txt As UIElement In CType(Me.Content, StackPanel).Children
CType(txt, TextBox).BorderBrush = New SolidColorBrush(Colors.White)
Next
Else
'For Each txt As UIElement In CType(Me.Content, StackPanel).Children
' CType(txt, TextBox).BorderBrush = New SolidColorBrush(Colors.Black)
'Next
End If
End Sub
Last edited by a moderator: