Like for real, I do not get it, I have x:Name parameter in my StackPanel, but for whatever reason it's inaccesible in xaml.cs
Here is XAML:
<ListView x:Name="LV2" Background="#484848"
BorderBrush="Transparent"
ItemsSource="{Binding Lessons}"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SizeChanged="LV2_SizeChanged">
<ListView.ItemTemplate>
<DataTemplate>
<ScrollViewer VerticalScrollBarVisibility="Hidden" Height="Auto" Width="Auto" Margin="0,0,20,0">
<StackPanel x:Name="SP" SizeChanged="SP_SizeChanged">
<TextBlock Width="Auto" FontSize="24" Foreground="Black" TextWrapping="Wrap">
<Run Text="{Binding LessonText}"/>
</TextBlock>
<Image Source="{Binding LessonImage}"/>
</StackPanel>
</ScrollViewer>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And xaml.cs
namespace ApkaJezykowa.MVVM.View
{
/// <summary>
/// Logika interakcji dla klasy FrenchLessonView.xaml
/// </summary>
public partial class FrenchLessonView : UserControl
{
public FrenchLessonView()
{
InitializeComponent();
}
private void SP_SizeChanged(object sender, SizeChangedEventArgs e)
{
SP.Height = HeightModel.Instance.Height;
//That one doesn't work
}
private void LV2_SizeChanged(object sender, SizeChangedEventArgs e)
{
LV2.Height = HeightModel.Instance.Height;
}
}
}
What is even the reason? I tried to do that with Scrollviewer too, result was the same, even removing other x:Name parameter (which works as it should).