Giter VIP home page Giter VIP logo

Comments (13)

alexrainman avatar alexrainman commented on June 12, 2024

If you take a look at the demo, i use StackLayout inside ScrollView and it works without issues.

<ScrollView>
    <StackLayout Padding="12" Spacing="12">
			
	<controls:CVLabel Text="Quod cum ita sit, paucae domus studiorum seriis cultibus antea celebratae nunc ludibriis ignaviae torpentis exundant, vocali sonu, perflabili tinnitu fidium resultantes. denique pro philosopho cantor et in locum oratoris doctor artium ludicrarum accitur et bybliothecis sepulcrorum ritu in perpetuum clausis organa fabricantur hydraulica, et lyrae ad speciem carpentorum ingentes tibiaeque et histrionici gestus instrumenta non levia."/>

    </StackLayout>
</ScrollView>

But, you have to use CVLabel. It's a custom control that set the height of the label depending on it's content.

public class CVLabel : Label
{
    public CVLabel()
    {
        SetBinding(Label.HeightRequestProperty, new Binding("WidthRequest", BindingMode.Default, new LabelHeightConverter(), this, null, this));
    }

    protected override void OnSizeAllocated(double width, double height)
    {
        base.OnSizeAllocated(width, height);

        WidthRequest = width;

        this.LayoutTo(new Rectangle(this.X, this.Y, width, height));

        this.InvalidateMeasure();
    }
}

from carouselview.

dashne avatar dashne commented on June 12, 2024

Ok,I used CVLabel but still cannot scroll I dont know I use formattedText of Label because there is some text needs to be colorized like Titles and numbers,here its my xaml code:

<ContentPage.Resources> <ResourceDictionary> <converter:PageToMainTextConverter x:Key="MainText" /> <converter:PageToFooterTextConverter x:Key="FooterText" /> <DataTemplate x:Key="PageData"> <StackLayout Orientation="Vertical"> <ScrollView VerticalOptions="FillAndExpand" Orientation="Vertical"> <control:CVLabel FormattedText="{Binding Page, Converter={StaticResource MainText}}" FontSize="30" HorizontalTextAlignment="End" /> </ScrollView> </StackLayout> </DataTemplate> </ResourceDictionary> </ContentPage.Resources> <StackLayout> <StackLayout /> <control:CarouselViewControl ItemsSource="{Binding Pages}" VerticalOptions="FillAndExpand" Orientation="Horizontal" HorizontalOptions="FillAndExpand" Position="{Binding PageIndex,Mode=TwoWay}" ItemTemplate="{StaticResource PageData}" x:Name="Pager"> </control:CarouselViewControl>

from carouselview.

alexrainman avatar alexrainman commented on June 12, 2024

You label is not wrapped by ScrollView

from carouselview.

dashne avatar dashne commented on June 12, 2024

sorry, I had problem with inserting code and still I have please Can you look at this now:
<ContentPage.Resources>
<ResourceDictionary>
<converter:PageToMainTextConverter x:Key="MainText" />
<converter:PageToFooterTextConverter x:Key="FooterText" />
<DataTemplate x:Key="PageData">
<StackLayout Orientation="Vertical">
<ScrollView VerticalOptions="FillAndExpand" Orientation="Vertical">
<control:CVLabel FormattedText="{Binding Page, Converter={StaticResource MainText}}"
FontSize="30"
HorizontalTextAlignment="End" />
</ScrollView>
</StackLayout>
</DataTemplate>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout>
<control:CarouselViewControl ItemsSource="{Binding Pages}"
VerticalOptions="FillAndExpand" Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
Position="{Binding PageIndex,Mode=TwoWay}"
ItemTemplate="{StaticResource PageData}"
x:Name="Pager">

    `</control:CarouselViewControl> `

from carouselview.

dashne avatar dashne commented on June 12, 2024

Thank you alexrainman, you guided me to the right way I added another overload measure method and passed FormattedString instead of string variable type,and in implementation I just converted it to string by
text.ToString(),then from LabelHeightConverter I used label.FormattedText and it works.

Again Thank you so much.

from carouselview.

alexrainman avatar alexrainman commented on June 12, 2024

Can you share your implementation?

from carouselview.

dashne avatar dashne commented on June 12, 2024

Off course:
int ITextMeter interface I added:

double MeasureTextSize(FormattedString text, double width, double fontSize, string fontName = null);

In Droid project: in TextMeterImplementation:

`public double MeasureTextSize(FormattedString text, double width, double fontSize, string fontName = null)
{
var textView = new TextView(global::Android.App.Application.Context);
textView.Typeface = GetTypeface(fontName);
textView.SetText(text.ToString(), TextView.BufferType.Normal);
textView.SetTextSize(ComplexUnitType.Px, (float)fontSize);

        int widthMeasureSpec = AViews.View.MeasureSpec.MakeMeasureSpec(
            (int)width, AViews.MeasureSpecMode.AtMost);
        int heightMeasureSpec = AViews.View.MeasureSpec.MakeMeasureSpec(
            0, AViews.MeasureSpecMode.Unspecified);

        textView.Measure(widthMeasureSpec, heightMeasureSpec);

        return (double)textView.MeasuredHeight;
    }`

In LabelHeightConverter I used:

var height = DependencyService.Get<ITextMeter>().MeasureTextSize(label.FormattedText, width, label.FontSize, label.FontFamily);

That's all.

from carouselview.

alexrainman avatar alexrainman commented on June 12, 2024

And iOS?

from carouselview.

dashne avatar dashne commented on June 12, 2024

I didn't tested it, sorry

from carouselview.

alexrainman avatar alexrainman commented on June 12, 2024

I released a new version with lot of fixes and improvements, including support for latest Forms.

from carouselview.

alexrainman avatar alexrainman commented on June 12, 2024

Does latest release solve this?

from carouselview.

alexrainman avatar alexrainman commented on June 12, 2024

If my work is helping you, please help me back: https://xamarinhq.wufoo.com/forms/nominate-a-xamarin-mvp/

from carouselview.

alexrainman avatar alexrainman commented on June 12, 2024

This is what i have done that is community visible:

  • Alex has been pretty active sharing his knowledge and answering questions in StackOverflow, GitHub and Xamarin Forums.
  • Alex has been open sourcing Xamarin components and plugin with the community, with more of 10 repositories being maintained on GitHub.
  • One of Alex's Xamarin.Forms plugin, the CarouselView, is currently being pulled into the Xamarin.Forms core (xamarin/Xamarin.Forms#853). As an stable widget, this control has become the standard for Xamarin.Forms carousel screens with more that 16K downloads in NuGet and more than 100 solved and not open issues.
  • Another Alex's plugin, the SegmentedControl (https://github.com/alexrainman/SegmentedControl), is a big candidate to be also pulled into Xamarin.Forms core.
  • Plus Xamarin.Forms UI related plugins, Alex shares plugins to set app icon Badge, Google Analytics and KeyChain access.
  • Alex shares his knowledge about cutting edge technologies like Couchbase NoSQL and MobileIron integration with Xamarin Apps.

from carouselview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.