Xamarin forms: Increase the editor height based on the character count












1















I have an editor like below in my xamarin forms project.



enter image description here



When I type a message on it I need to increase the height of the editor based on the number of characters.



Here is my complete code of bottom part, I added a frame layout for making the entry corners are round:



<StackLayout
HorizontalOptions="FillAndExpand"
x:Name="tweetBox"
VerticalOptions="End"
Margin="0,0,0,10"
BackgroundColor="#f2f2f2"
Orientation="Horizontal">

<Image
WidthRequest="25"
HeightRequest="25"
VerticalOptions="Center"
Source="ic_add_blue_xx.png"
Margin="10,5,-5,5">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="ShowPicureOptions"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>

<Frame
Padding="0"
Margin="5,5,0,5"
HorizontalOptions="FillAndExpand"
CornerRadius="10">

<Editor
x:Name="tweetText"
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
FontFamily="Bold"
BackgroundColor="White"
TextColor="#959595"
AutoSize="TextChanges"
PlaceholderColor="#959595"
Placeholder=" Enter Message..."/>
</Frame>

<Image
VerticalOptions="Center"
WidthRequest="25"
Margin="5,5,10,5"
HeightRequest="25"
HorizontalOptions="End"
Source="ic_send_xx.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="SendTweet_Icon_Clicked"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</StackLayout>









share|improve this question

























  • Your code is working perfectly for me. Instead of executing, Provide Text properly & check in windows forms previewer.

    – CGPA6.4
    Nov 26 '18 at 6:12











  • @CGPA6.4 For me, the no change in the height of the entry, tried after removing the frame but no change. The text is going in a single line, no multiple lines are coming.

    – Sreejith Sree
    Nov 26 '18 at 6:30













  • @CGPA6.4 I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:25








  • 1





    Remove Orientation="Horizontal" from StackLayout than it should work.

    – CGPA6.4
    Nov 26 '18 at 7:41











  • @CGPA6.4 Removing Orientation="Horizontal" from StackLayout is working, but the icons are in vertical format, I need those 3 icons on the bottom in the horizontal orientation

    – Sreejith Sree
    Nov 26 '18 at 8:32


















1















I have an editor like below in my xamarin forms project.



enter image description here



When I type a message on it I need to increase the height of the editor based on the number of characters.



Here is my complete code of bottom part, I added a frame layout for making the entry corners are round:



<StackLayout
HorizontalOptions="FillAndExpand"
x:Name="tweetBox"
VerticalOptions="End"
Margin="0,0,0,10"
BackgroundColor="#f2f2f2"
Orientation="Horizontal">

<Image
WidthRequest="25"
HeightRequest="25"
VerticalOptions="Center"
Source="ic_add_blue_xx.png"
Margin="10,5,-5,5">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="ShowPicureOptions"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>

<Frame
Padding="0"
Margin="5,5,0,5"
HorizontalOptions="FillAndExpand"
CornerRadius="10">

<Editor
x:Name="tweetText"
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
FontFamily="Bold"
BackgroundColor="White"
TextColor="#959595"
AutoSize="TextChanges"
PlaceholderColor="#959595"
Placeholder=" Enter Message..."/>
</Frame>

<Image
VerticalOptions="Center"
WidthRequest="25"
Margin="5,5,10,5"
HeightRequest="25"
HorizontalOptions="End"
Source="ic_send_xx.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="SendTweet_Icon_Clicked"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</StackLayout>









share|improve this question

























  • Your code is working perfectly for me. Instead of executing, Provide Text properly & check in windows forms previewer.

    – CGPA6.4
    Nov 26 '18 at 6:12











  • @CGPA6.4 For me, the no change in the height of the entry, tried after removing the frame but no change. The text is going in a single line, no multiple lines are coming.

    – Sreejith Sree
    Nov 26 '18 at 6:30













  • @CGPA6.4 I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:25








  • 1





    Remove Orientation="Horizontal" from StackLayout than it should work.

    – CGPA6.4
    Nov 26 '18 at 7:41











  • @CGPA6.4 Removing Orientation="Horizontal" from StackLayout is working, but the icons are in vertical format, I need those 3 icons on the bottom in the horizontal orientation

    – Sreejith Sree
    Nov 26 '18 at 8:32
















1












1








1


1






I have an editor like below in my xamarin forms project.



enter image description here



When I type a message on it I need to increase the height of the editor based on the number of characters.



Here is my complete code of bottom part, I added a frame layout for making the entry corners are round:



<StackLayout
HorizontalOptions="FillAndExpand"
x:Name="tweetBox"
VerticalOptions="End"
Margin="0,0,0,10"
BackgroundColor="#f2f2f2"
Orientation="Horizontal">

<Image
WidthRequest="25"
HeightRequest="25"
VerticalOptions="Center"
Source="ic_add_blue_xx.png"
Margin="10,5,-5,5">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="ShowPicureOptions"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>

<Frame
Padding="0"
Margin="5,5,0,5"
HorizontalOptions="FillAndExpand"
CornerRadius="10">

<Editor
x:Name="tweetText"
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
FontFamily="Bold"
BackgroundColor="White"
TextColor="#959595"
AutoSize="TextChanges"
PlaceholderColor="#959595"
Placeholder=" Enter Message..."/>
</Frame>

<Image
VerticalOptions="Center"
WidthRequest="25"
Margin="5,5,10,5"
HeightRequest="25"
HorizontalOptions="End"
Source="ic_send_xx.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="SendTweet_Icon_Clicked"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</StackLayout>









share|improve this question
















I have an editor like below in my xamarin forms project.



enter image description here



When I type a message on it I need to increase the height of the editor based on the number of characters.



Here is my complete code of bottom part, I added a frame layout for making the entry corners are round:



<StackLayout
HorizontalOptions="FillAndExpand"
x:Name="tweetBox"
VerticalOptions="End"
Margin="0,0,0,10"
BackgroundColor="#f2f2f2"
Orientation="Horizontal">

<Image
WidthRequest="25"
HeightRequest="25"
VerticalOptions="Center"
Source="ic_add_blue_xx.png"
Margin="10,5,-5,5">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="ShowPicureOptions"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>

<Frame
Padding="0"
Margin="5,5,0,5"
HorizontalOptions="FillAndExpand"
CornerRadius="10">

<Editor
x:Name="tweetText"
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
FontFamily="Bold"
BackgroundColor="White"
TextColor="#959595"
AutoSize="TextChanges"
PlaceholderColor="#959595"
Placeholder=" Enter Message..."/>
</Frame>

<Image
VerticalOptions="Center"
WidthRequest="25"
Margin="5,5,10,5"
HeightRequest="25"
HorizontalOptions="End"
Source="ic_send_xx.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="SendTweet_Icon_Clicked"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</StackLayout>






xamarin.forms height editor






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 7:22







Sreejith Sree

















asked Nov 23 '18 at 13:20









Sreejith SreeSreejith Sree

470217




470217













  • Your code is working perfectly for me. Instead of executing, Provide Text properly & check in windows forms previewer.

    – CGPA6.4
    Nov 26 '18 at 6:12











  • @CGPA6.4 For me, the no change in the height of the entry, tried after removing the frame but no change. The text is going in a single line, no multiple lines are coming.

    – Sreejith Sree
    Nov 26 '18 at 6:30













  • @CGPA6.4 I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:25








  • 1





    Remove Orientation="Horizontal" from StackLayout than it should work.

    – CGPA6.4
    Nov 26 '18 at 7:41











  • @CGPA6.4 Removing Orientation="Horizontal" from StackLayout is working, but the icons are in vertical format, I need those 3 icons on the bottom in the horizontal orientation

    – Sreejith Sree
    Nov 26 '18 at 8:32





















  • Your code is working perfectly for me. Instead of executing, Provide Text properly & check in windows forms previewer.

    – CGPA6.4
    Nov 26 '18 at 6:12











  • @CGPA6.4 For me, the no change in the height of the entry, tried after removing the frame but no change. The text is going in a single line, no multiple lines are coming.

    – Sreejith Sree
    Nov 26 '18 at 6:30













  • @CGPA6.4 I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:25








  • 1





    Remove Orientation="Horizontal" from StackLayout than it should work.

    – CGPA6.4
    Nov 26 '18 at 7:41











  • @CGPA6.4 Removing Orientation="Horizontal" from StackLayout is working, but the icons are in vertical format, I need those 3 icons on the bottom in the horizontal orientation

    – Sreejith Sree
    Nov 26 '18 at 8:32



















Your code is working perfectly for me. Instead of executing, Provide Text properly & check in windows forms previewer.

– CGPA6.4
Nov 26 '18 at 6:12





Your code is working perfectly for me. Instead of executing, Provide Text properly & check in windows forms previewer.

– CGPA6.4
Nov 26 '18 at 6:12













@CGPA6.4 For me, the no change in the height of the entry, tried after removing the frame but no change. The text is going in a single line, no multiple lines are coming.

– Sreejith Sree
Nov 26 '18 at 6:30







@CGPA6.4 For me, the no change in the height of the entry, tried after removing the frame but no change. The text is going in a single line, no multiple lines are coming.

– Sreejith Sree
Nov 26 '18 at 6:30















@CGPA6.4 I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

– Sreejith Sree
Nov 26 '18 at 7:25







@CGPA6.4 I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

– Sreejith Sree
Nov 26 '18 at 7:25






1




1





Remove Orientation="Horizontal" from StackLayout than it should work.

– CGPA6.4
Nov 26 '18 at 7:41





Remove Orientation="Horizontal" from StackLayout than it should work.

– CGPA6.4
Nov 26 '18 at 7:41













@CGPA6.4 Removing Orientation="Horizontal" from StackLayout is working, but the icons are in vertical format, I need those 3 icons on the bottom in the horizontal orientation

– Sreejith Sree
Nov 26 '18 at 8:32







@CGPA6.4 Removing Orientation="Horizontal" from StackLayout is working, but the icons are in vertical format, I need those 3 icons on the bottom in the horizontal orientation

– Sreejith Sree
Nov 26 '18 at 8:32














1 Answer
1






active

oldest

votes


















3














It is built-in to Xamarin.Forms now. Simply use the Editor control and set the AutoSize property to TextChanges. Note that the auto sizing will not work when you set a HeightRequest.



More information here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/editor



Update: from the comments we resolved that replacing the StackLayout with a Grid helps you achieve the result. This is because a StackLayout just takes up the space that is (initially) taken up by its children. A Grid is able to grow dynamically.






share|improve this answer


























  • Not working after adding autosize property. when typing message, the text is showing in the same line. Only a single line is showing, not going to the new line after completing the first line and no change in the editor height.

    – Sreejith Sree
    Nov 23 '18 at 14:24











  • Please update your question with some code you have that is not working for you

    – Gerald Versluis
    Nov 23 '18 at 15:50











  • I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:26








  • 1





    Try replacing your StackLayout with a Grid

    – Gerald Versluis
    Nov 26 '18 at 8:24






  • 1





    I think nothing is built-in for this. Probably the OS will have some kind of maximum. Else you will need to hook into the SizeChanged event of the Editor and implement something for it yourself

    – Gerald Versluis
    Nov 26 '18 at 10:35












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447494%2fxamarin-forms-increase-the-editor-height-based-on-the-character-count%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














It is built-in to Xamarin.Forms now. Simply use the Editor control and set the AutoSize property to TextChanges. Note that the auto sizing will not work when you set a HeightRequest.



More information here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/editor



Update: from the comments we resolved that replacing the StackLayout with a Grid helps you achieve the result. This is because a StackLayout just takes up the space that is (initially) taken up by its children. A Grid is able to grow dynamically.






share|improve this answer


























  • Not working after adding autosize property. when typing message, the text is showing in the same line. Only a single line is showing, not going to the new line after completing the first line and no change in the editor height.

    – Sreejith Sree
    Nov 23 '18 at 14:24











  • Please update your question with some code you have that is not working for you

    – Gerald Versluis
    Nov 23 '18 at 15:50











  • I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:26








  • 1





    Try replacing your StackLayout with a Grid

    – Gerald Versluis
    Nov 26 '18 at 8:24






  • 1





    I think nothing is built-in for this. Probably the OS will have some kind of maximum. Else you will need to hook into the SizeChanged event of the Editor and implement something for it yourself

    – Gerald Versluis
    Nov 26 '18 at 10:35
















3














It is built-in to Xamarin.Forms now. Simply use the Editor control and set the AutoSize property to TextChanges. Note that the auto sizing will not work when you set a HeightRequest.



More information here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/editor



Update: from the comments we resolved that replacing the StackLayout with a Grid helps you achieve the result. This is because a StackLayout just takes up the space that is (initially) taken up by its children. A Grid is able to grow dynamically.






share|improve this answer


























  • Not working after adding autosize property. when typing message, the text is showing in the same line. Only a single line is showing, not going to the new line after completing the first line and no change in the editor height.

    – Sreejith Sree
    Nov 23 '18 at 14:24











  • Please update your question with some code you have that is not working for you

    – Gerald Versluis
    Nov 23 '18 at 15:50











  • I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:26








  • 1





    Try replacing your StackLayout with a Grid

    – Gerald Versluis
    Nov 26 '18 at 8:24






  • 1





    I think nothing is built-in for this. Probably the OS will have some kind of maximum. Else you will need to hook into the SizeChanged event of the Editor and implement something for it yourself

    – Gerald Versluis
    Nov 26 '18 at 10:35














3












3








3







It is built-in to Xamarin.Forms now. Simply use the Editor control and set the AutoSize property to TextChanges. Note that the auto sizing will not work when you set a HeightRequest.



More information here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/editor



Update: from the comments we resolved that replacing the StackLayout with a Grid helps you achieve the result. This is because a StackLayout just takes up the space that is (initially) taken up by its children. A Grid is able to grow dynamically.






share|improve this answer















It is built-in to Xamarin.Forms now. Simply use the Editor control and set the AutoSize property to TextChanges. Note that the auto sizing will not work when you set a HeightRequest.



More information here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/editor



Update: from the comments we resolved that replacing the StackLayout with a Grid helps you achieve the result. This is because a StackLayout just takes up the space that is (initially) taken up by its children. A Grid is able to grow dynamically.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 26 '18 at 9:15

























answered Nov 23 '18 at 13:46









Gerald VersluisGerald Versluis

17.8k43659




17.8k43659













  • Not working after adding autosize property. when typing message, the text is showing in the same line. Only a single line is showing, not going to the new line after completing the first line and no change in the editor height.

    – Sreejith Sree
    Nov 23 '18 at 14:24











  • Please update your question with some code you have that is not working for you

    – Gerald Versluis
    Nov 23 '18 at 15:50











  • I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:26








  • 1





    Try replacing your StackLayout with a Grid

    – Gerald Versluis
    Nov 26 '18 at 8:24






  • 1





    I think nothing is built-in for this. Probably the OS will have some kind of maximum. Else you will need to hook into the SizeChanged event of the Editor and implement something for it yourself

    – Gerald Versluis
    Nov 26 '18 at 10:35



















  • Not working after adding autosize property. when typing message, the text is showing in the same line. Only a single line is showing, not going to the new line after completing the first line and no change in the editor height.

    – Sreejith Sree
    Nov 23 '18 at 14:24











  • Please update your question with some code you have that is not working for you

    – Gerald Versluis
    Nov 23 '18 at 15:50











  • I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

    – Sreejith Sree
    Nov 26 '18 at 7:26








  • 1





    Try replacing your StackLayout with a Grid

    – Gerald Versluis
    Nov 26 '18 at 8:24






  • 1





    I think nothing is built-in for this. Probably the OS will have some kind of maximum. Else you will need to hook into the SizeChanged event of the Editor and implement something for it yourself

    – Gerald Versluis
    Nov 26 '18 at 10:35

















Not working after adding autosize property. when typing message, the text is showing in the same line. Only a single line is showing, not going to the new line after completing the first line and no change in the editor height.

– Sreejith Sree
Nov 23 '18 at 14:24





Not working after adding autosize property. when typing message, the text is showing in the same line. Only a single line is showing, not going to the new line after completing the first line and no change in the editor height.

– Sreejith Sree
Nov 23 '18 at 14:24













Please update your question with some code you have that is not working for you

– Gerald Versluis
Nov 23 '18 at 15:50





Please update your question with some code you have that is not working for you

– Gerald Versluis
Nov 23 '18 at 15:50













I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

– Sreejith Sree
Nov 26 '18 at 7:26







I created a sample project and this feature is working fine on there, but when I apply this to the main project it is not working. I added the entire code of my bottom part(+ image, editor and send icon) to the question, can you please check?

– Sreejith Sree
Nov 26 '18 at 7:26






1




1





Try replacing your StackLayout with a Grid

– Gerald Versluis
Nov 26 '18 at 8:24





Try replacing your StackLayout with a Grid

– Gerald Versluis
Nov 26 '18 at 8:24




1




1





I think nothing is built-in for this. Probably the OS will have some kind of maximum. Else you will need to hook into the SizeChanged event of the Editor and implement something for it yourself

– Gerald Versluis
Nov 26 '18 at 10:35





I think nothing is built-in for this. Probably the OS will have some kind of maximum. Else you will need to hook into the SizeChanged event of the Editor and implement something for it yourself

– Gerald Versluis
Nov 26 '18 at 10:35




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447494%2fxamarin-forms-increase-the-editor-height-based-on-the-character-count%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini