맥에서 자마린 스튜디오로 자마린폼기반으로 프로젝트를 생성합니다. 아래와 같이 재물 코드를 코딩합니다.
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DemoDataBinding.DemoWebView">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness"
iOS="10, 20, 10, 0" Android="10, 0" WinPhone="10, 0" />
</ContentPage.Padding>
<StackLayout>
<Entry Keyboard="Url" Placeholder="web address"
Completed="OnEntryCompleted" />
<StackLayout Orientation="Horizontal"
BindingContext="{x:Reference webView}">
<Button Text="⇐" FontSize="Large"
HorizontalOptions="FillAndExpand"
IsEnabled="{Binding CanGoBack}" Clicked="OnGoBackClicked" />
<Button Text="⇒" FontSize="Large"
HorizontalOptions="FillAndExpand" IsEnabled="{Binding CanGoForward}" Clicked="OnGoForwardClicked" />
</StackLayout>
<WebView x:Name="webView" VerticalOptions="FillAndExpand"
Source="https://xamarin.com" />
</StackLayout>
</ContentPage>
using System.Collections.Generic;
using Xamarin.Forms;
namespace DemoDataBinding
{
public partial class DemoWebView : ContentPage
{
public DemoWebView()
{
InitializeComponent();
}
void OnEntryCompleted(object sender, EventArgs args)
{
webView.Source = ((Entry)sender).Text;
}
void OnGoBackClicked(object sender, EventArgs args)
{
webView.GoBack();
}
void OnGoForwardClicked(object sender, EventArgs args)
{
webView.GoForward();
}
}
}
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace DemoDataBinding
{
public partial class DemoWebView : ContentPage
{
public DemoWebView()
{
InitializeComponent();
}
void OnEntryCompleted(object sender, EventArgs args)
{
webView.Source = ((Entry)sender).Text;
}
void OnGoBackClicked(object sender, EventArgs args)
{
webView.GoBack();
}
void OnGoForwardClicked(object sender, EventArgs args)
{
webView.GoForward();
}
}
}
using System.Collections.Generic;
using Xamarin.Forms;
namespace DemoDataBinding
{
public partial class DemoWebView : ContentPage
{
public DemoWebView()
{
InitializeComponent();
}
void OnEntryCompleted(object sender, EventArgs args)
{
webView.Source = ((Entry)sender).Text;
}
void OnGoBackClicked(object sender, EventArgs args)
{
webView.GoBack();
}
void OnGoForwardClicked(object sender, EventArgs args)
{
webView.GoForward();
}
}
}
실행하면 아래와 같이 실행됩니다.
댓글 없음:
댓글 쓰기
참고: 블로그의 회원만 댓글을 작성할 수 있습니다.