Well, I have a problem with a function that I get from there
[VB.NET]
Public Class TreeHelper
Public Shared Function FindVisualChildByName(Of T As FrameworkElement)(parent As DependencyObject, name As String) As T
Dim child As T = Nothing
For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(parent) - 1
Dim ch = VisualTreeHelper.GetChild(parent, i)
child = TryCast(ch, T)
If child IsNot Nothing AndAlso child.Name = name Then
Exit For
Else
child = FindVisualChildByName(Of T)(ch, name)
End If
If child IsNot Nothing Then
Exit For
End If
Next
Return child
End Function
End Class
And the XAML part:
<TabItem x:Name="itemControls"
Height="50"
Margin="0"
VerticalAlignment="Top"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Padding="6,1">
<TabItem.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image x:Name="iconKB"
Width="25"
Height="25"
Stretch="Fill" />
</StackPanel>
</DataTemplate>
</TabItem.HeaderTemplate>
</TabItem>
So, I tried to edit iconKB image's source with the following syntax:
TreeHelper.FindVisualChildByName(Of Image)(itemControls, "iconKB").Source = New BitmapImage(New Uri("pack://application:,,,/Resources/icons/Keyboard.png"))
But for some reason it doesn't change. It keeps blank. (And the problem is not in New BitmapImage(New Uri("pack://application:,,,/Resources/icons/Keyboard.png"))
it's completely checked with another image controls)
Thanks in advance.