Weltista
Topic Author
Posts: 11
Joined: 14 Jun 2014, 23:52

[Unity] Binding to struct type

28 Jul 2014, 19:44

Hi,

I was wondering if there is a way to bind View to a struct type. Say I have the class that contains struct type:
  public SpaceShip myShip;

[Noesis.Extended]
public class SpaceShip: Noesis.BaseComponent {

	private Damage_Resist _current_Resist;
	public Damage_Resist current_Resist {
		get { return _current_Resist; }
		set	{
			if (_current_Resist != value) {
				_current_Resist = value;
				NotifyPropertyChanged("current_Resist");
			}
		}
	} 
}

public struct Damage_Resist { 
	public float resist_Kinet;
	public float resist_Gravi;
	
	public Damage_Resist (float r_kin, float r_gravi) {
		resist_Kinet = r_kin;
		resist_Gravi = r_gravi;
	}
 
After setting DataContext to myShip, is it possible to reference parameters it in xaml like: Text="{Binding current_Resist.resist_Kinet } ?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: [Unity] Binding to struct type

29 Jul 2014, 03:30

Sorry but we only support to bind to properties (not even fields) of classes that at least inherit from Noesis.BaseComponent and have the [Noesis.Extended] attribute.

Many questions have been asked about this constraints, and we are working on ways to improve and even remove them at all. We expect to have a better extensibility API in a future release.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: [Unity] Binding to struct type

29 Jul 2014, 15:09

As a workaround if you convert Damage_Resist to a class, inherit from Noesis.BaseComponent, and implement each field as property you should be able to bind from the XAML the way you expressed: Text="{Binding current_Resist.resist_Kinet }

Who is online

Users browsing this forum: No registered users and 38 guests