28
loading...
This website collects cookies to deliver better user experience
dotnet new -i Uno.ProjectTemplates.Dotnet
dotnet new unoapp-net6 -o UnoSample -M=false -skia-wpf=false
dotnet run --project UnoSample.Skia.Gtk
warn: Windows.UI.Composition.TextVisual[0]
The font Segoe UI could not be found, using system default
warn: Windows.UI.Xaml.UIElement[0]
The BorderThicknessProperty dependency property does not exist on Uno.UI.Xaml.Core.RootVisual
<Page
x:Class="UnoSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoSample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
FontFamily="Noto Sans CJK JP">
<StackPanel>
<TextBlock x:Name="txt"
Text="Hello, world!"
Margin="20"
FontSize="30" />
<Button Content="Update" x:Name="buttonRefresh" Margin="300 10 10 30" FontSize="16" Width="150" Height="80"/>
</StackPanel>
</Page>
using System;
using Windows.UI.Xaml.Controls;
namespace UnoSample
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
// set FontFamily
this.FontFamily = new FontFamily("Noto Sans CJK JP");
}
}
}
<Page
x:Class="UnoSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoSample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
FontFamily="Noto Sans CJK JP">
<StackPanel>
<TextBlock x:Name="txt"
Text="Hello, world!"
Margin="20"
FontSize="30" />
<Button Content="Update" x:Name="buttonRefresh" Margin="300 10 10 30" FontSize="16" Width="150" Height="80" FontFamily="Noto Sans CJK JP" />
</StackPanel>
</Page>
...
<StackPanel>
<TextBlock x:Name="txt"
Text="{Binding PageTitle}"
Margin="20"
FontSize="30" />
<Button Content="Update" x:Name="buttonRefresh" Margin="300 10 10 30" FontSize="16" Width="150" Height="80" FontFamily="Noto Sans CJK JP" />
</StackPanel>
</Page>
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using UnoSample.ViewModels;
namespace UnoSample
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.DataContext = new MainPageViewModel();
}
}
}
namespace UnoSample.ViewModels
{
public class MainPageViewModel
{
public string PageTitle { get; set; } = "Hello World";
public SampleButtonClick ButtonClick { get; set; } = new SampleButtonClick();
public void SampleClicked()
{
Console.WriteLine("AAA");
}
}
}
using System.Windows.Input;
namespace UnoSample.ViewModels
{
public class SampleButtonClick: ICommand
{
public event EventHandler? CanExecuteChanged;
public bool CanExecute(object? parameter)
{
return true;
}
public void Execute(object? parameter)
{
Console.WriteLine("Executed");
}
}
}
...
<StackPanel>
...
<!-- Error -->
<Button Content="Update" x:Name="buttonRefresh" Margin="300 10 10 30" FontSize="16" Width="150" Height="80" FontFamily="Noto Sans CJK JP"
Click="{Binding ButtonClick}" />
</StackPanel>
</Page>
...
<StackPanel>
...
<Button Content="Update" x:Name="buttonRefresh" Margin="300 10 10 30" FontSize="16" Width="150" Height="80" FontFamily="Noto Sans CJK JP"
Click="OnClick"/>
</StackPanel>
</Page>
...
namespace UnoSample
{
public sealed partial class MainPage : Page
{
...
private void OnClick(object sender, RoutedEventArgs e)
{
(this.DataContext as MainPageViewModel)?.SampleClicked();
}
}
}
...
<StackPanel>
...
<Button Content="Update" x:Name="buttonRefresh" Margin="300 10 10 30" FontSize="16" Width="150" Height="80" FontFamily="Noto Sans CJK JP"
Command="{Binding ButtonClick}"/>
</StackPanel>
</Page>