Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
U
UniRxNoesisBridge
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 0
    • Merge requests 0
  • Requirements
    • Requirements
    • List
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • tkaczz
  • UniRxNoesisBridge
  • Wiki
  • How to use

Last edited by tkaczz Mar 18, 2020
Page history

How to use

Assume that we have example noesis project with view model like below...

#if UNITY_5_3_OR_NEWER
using Noesis;
using UniRxNoesisBridge;

#else
using System.Windows.Media;
#endif

namespace UI {
    /// <summary>
    /// Interaction logic for application ViewModel
    /// </summary>
    public partial class ViewModel {
        public BindableReactiveProperty<Color> TopColor { get; set; }
        //public Color TopColor { get; set; }

        public Color BottomColor { get; set; }

        public ViewModel() {
            TopColor = new BindableReactiveProperty<Color>(Color.FromRgb(16, 102, 157), "TopColor.Value");
            TopColor.Value = Color.FromRgb(16, 0, 0);
            //TopColor = Color.FromRgb(17, 102, 157);
            BottomColor = Color.FromRgb(18, 57, 87);
            int i = 0;
        }
    }
}

and code-behind of MainWindow ...

#if UNITY_5_3_OR_NEWER
#define NOESIS
using Noesis;
#else
using System;
using System.Windows;
using System.Windows.Controls;
#endif

namespace UI {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : UserControl {
        public MainWindow() {
            InitializeComponent();

            DataContext = new ViewModel();
        }

#if NOESIS
        private void InitializeComponent() {
            Noesis.GUI.LoadComponent(this, "Assets/NoesisGUI/Sample/MainWindow.xaml");
        }
#endif
    }
}

We have to bind to <variable_name>.Value to get any messages about changed value

<UserControl x:Class="UI.MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>
    <Grid.Background>
      <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
        <GradientStop Offset="0" Color="{Binding TopColor.Value}"/>
        <GradientStop Offset="1" Color="{Binding BottomColor}"/>
      </LinearGradientBrush>
    </Grid.Background>
    <Viewbox>
      <TextBlock Text="Hello World!" Foreground="White" Margin="100"/>
    </Viewbox>
  </Grid>
</UserControl>
Clone repository
  • How to use