Как реализовать htmleditor в формах xamarin

#xamarin.forms #visual-studio-2019

#xamarin.forms #visual-studio-2019

Вопрос:

Мне нравится внедрять htmleditor в xamarin forms, я нашел один пакет, такой как TEditor и TEditor.VK. Оба не предоставляют код xaml, пожалуйста, предоставьте ссылку для htmleditor или дайте мне предложение по решению проблемы

Ответ №1:

Вы можете загрузить исходный файл с GitHub. https://github.com/XAM-Consulting/TEditor

Он предоставляет пример кода на c # TEditorHtmlView . https://github.com/XAM-Consulting/TEditor/blob/master/Sample/TEditor .Формы.Пример/TEditorHtmlView.cs

Вы можете проверить приведенный ниже xaml.

  <ContentPage.Content>
    <StackLayout Orientation="Vertical">
        <Button
            Clicked="Button_Clicked"
            HeightRequest="100"
            Text="HTML Editor" />
        <WebView x:Name="_displayWebView" HeightRequest="500" />
    </StackLayout>
</ContentPage.Content>
  

Код, лежащий в основе:

  async void Button_Clicked(object sender, EventArgs e)
    {
        await ShowTEditor();
    }
    async Task ShowTEditor()
    {
        TEditorResponse response = await CrossTEditor.Current.ShowTEditor("<!-- This is an HTML comment --><p>This is a test of the <strong style="font-size:20px">TEditor</strong> by <a title="XAM consulting" href="http://www.xam-consulting.com">XAM consulting</a></p>");
        if (response.IsSave)
        {
            if (response.HTML != null)
            {
                _displayWebView.Source = new HtmlWebViewSource() { Html = response.HTML };
            }
        }
    }