Created
June 22, 2018 18:50
-
-
Save gritsenko/c175d718881eb2638e416b4767a88218 to your computer and use it in GitHub Desktop.
No refresh on text changed on uno platform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page | |
x:Class="UnoTest1.MainPage" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="using:UnoTest1" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
mc:Ignorable="d" | |
x:Name="Page"> | |
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | |
<StackPanel HorizontalAlignment="Stretch" > | |
<TextBlock x:Name="TextBlock1" | |
Text="{Binding TbText}" Margin="20" FontSize="30" | |
HorizontalAlignment="Center"/> | |
<Button HorizontalAlignment="Center" | |
Margin="24" | |
MinWidth="200" | |
Height="48" | |
Click="ButtonBase_OnClick" | |
Content="Mega button"></Button> | |
</StackPanel> | |
</Grid> | |
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices.WindowsRuntime; | |
using Windows.Foundation; | |
using Windows.Foundation.Collections; | |
using Windows.Storage; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Controls.Primitives; | |
using Windows.UI.Xaml.Data; | |
using Windows.UI.Xaml.Input; | |
using Windows.UI.Xaml.Media; | |
using Windows.UI.Xaml.Navigation; | |
#if __IOS__ | |
using AVFoundation; | |
using Foundation; | |
#endif | |
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 | |
namespace UnoTest1 | |
{ | |
public class ViewModel : INotifyPropertyChanged | |
{ | |
private string _tbText = "THIS IS TEXT"; | |
public string TbText | |
{ | |
get => _tbText; | |
set | |
{ | |
_tbText = value; | |
OnPropertyChanged(); | |
} | |
} | |
public event PropertyChangedEventHandler PropertyChanged; | |
private void OnPropertyChanged([CallerMemberName] string propertyName = null) | |
{ | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
/// <summary> | |
/// An empty page that can be used on its own or navigated to within a Frame. | |
/// </summary> | |
public sealed partial class MainPage : Page | |
{ | |
ViewModel _vm = new ViewModel(); | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
this.DataContext = _vm; | |
} | |
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) | |
{ | |
_vm.TbText = "Button clicked!"; | |
} | |
// var assembly = typeof(MainPage).GetTypeInfo().Assembly; | |
// var stream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".Assets.collect.wav"); | |
//#if WINDOWS_UWP | |
// MediaElement mysong = new MediaElement(); | |
// mysong.SetSource(stream.AsRandomAccessStream(), "audio/wav"); | |
// mysong.Play(); | |
//#endif | |
//#if __IOS__ | |
// var aus = new AudioService(stream); | |
// aus.PlaySound(); | |
//#endif | |
// } | |
//#if __IOS__ | |
// class AudioService | |
// { | |
// private AVAudioPlayer _ringtoneAudioPlayer; | |
// public AudioService(Stream source) | |
// { | |
// _ringtoneAudioPlayer = AVAudioPlayer.FromData(NSData.FromStream(source)); | |
// _ringtoneAudioPlayer.NumberOfLoops = 1; // infinite | |
// } | |
// public void PlaySound() | |
// { | |
// if (_ringtoneAudioPlayer != null) | |
// { | |
// _ringtoneAudioPlayer.Stop(); | |
// } | |
// _ringtoneAudioPlayer.Play(); | |
// } | |
// public void StopSound() | |
// { | |
// if (_ringtoneAudioPlayer != null) | |
// { | |
// _ringtoneAudioPlayer.Stop(); | |
// } | |
// } | |
// } | |
//#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment