Issue
How can i call InvalidateSurface method in this case? This method does not refer to the bindable object, but to the xaml element itself. I'm new to app development and I really need to figure this out.
Part of my xaml file
<StackLayout>
<ListView
CachingStrategy="RecycleElement"
HasUnevenRows="True"
ItemsSource="{Binding TheoryContentList}"
SelectionMode="None"
SeparatorVisibility="None"
x:Name="listView">
<ListView.ItemTemplate>
<DataTemplate x:DataType="model:Wrapper">
<ViewCell>
<StackLayout>
<ScrollView>
<math:TextView x:Name="textView" LaTeX="{Binding Formula}" FontSize="{Binding Source={x:Reference TheoryPage1},Path=BindingContext.FSize}" HeightRequest="{Binding HeightReq}"/>
</ScrollView>
<Label LineBreakMode="WordWrap" HeightRequest="{Binding LabelHeightReq}" HorizontalTextAlignment="End" Margin="15, 0">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding BoldText}" FontAttributes="Bold"/>
<Span Text="{Binding Text1}" FontSize="Small" FontAttributes="Italic"/>
<Span x:Name="{Binding }" Text="{Binding Link.Text}" FontSize="Small" TextDecorations="Underline" FontAttributes="Italic" TextColor="Blue">
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference TheoryPage1},Path=BindingContext.LinkTappedCommand}" CommandParameter="{Binding Link}"/>
</Span.GestureRecognizers>
</Span>
<Span Text="{Binding Text2}"/>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Label x:Name="linkLabel" FontSize="Small" TextColor="Gray" Padding="0" Margin="15,0" HorizontalTextAlignment="Start"/>
</StackLayout>
My code behind
public TheoryPage()
{
InitializeComponent();
BindingContext = _viewModel = new TheoryViewModel();
textView.InvaludateSurface();
}
Solution
To solve this problem i used a wrapper class:
public class MyTextView : TextView
{
public MyTextView()
{
InvalidateSurface();
}
}
And used this class in xaml file:
<views:MyTextView x:Name="textView" LaTeX="{Binding Formula}" Margin="15, 5"/>
Answered By - Андрей Ерзунов
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.