General questions about bindings, converters etc.
Hi,
I'd like to know what can and can't be done in Noesis GUI for Unity compared to the c++ version.
For example, can I implement valueconverters in the Unity version?
By looking through the docs it seems like it's only possible in the c++ version, and that bindings should be used in Unity.
But reading the reviews in the Asset Store, I saw one post that said that you support valueconverters.
If it's possible to use them from Unity, how is it done. Is it covered in the doc somewhere?
And when it comes to bindings, is it possible to get some kind of feedback to the bound class if the visual tree (or the bound control) has been changed / invalidated?
You see, what I plan to do is to use bindings for setting up correct sizes of controls at runtime, depending on current screen-resolution.
Therefore it would be great to know when a part or all of the visual tree is being redrawn, so that I can re-calculate the bound values and mark them as changed at that time.
I can solve it by polling the current screen resolution in Unity, but it feels like a hack, especially if there's a cleaner solution.
If there's actually support for converters I'll probably use those instead of bindings.
And one last thing; is there some automated way to hook each xaml-control with a certain class to an individual instance of a [Noesis.Extended]-class in Unity that has the same class-name?
Sort of like code-behind?
I know that I can use SetDataContext to make that connection, but if there's a way to do it without manually looping through or searching for controls in the visual tree when entering play-mode that would be super.
All of these questions come from a wish to find the best and most effective way to use Noesis in Unity for semi-large to large enterprise applications. I love the freedom and lack of clutter that Noesis brings to the table, and I don't want to miss out on something just because I haven't managed to find the correct documentation.
Best regards,
Anders
I'd like to know what can and can't be done in Noesis GUI for Unity compared to the c++ version.
For example, can I implement valueconverters in the Unity version?
By looking through the docs it seems like it's only possible in the c++ version, and that bindings should be used in Unity.
But reading the reviews in the Asset Store, I saw one post that said that you support valueconverters.
If it's possible to use them from Unity, how is it done. Is it covered in the doc somewhere?
And when it comes to bindings, is it possible to get some kind of feedback to the bound class if the visual tree (or the bound control) has been changed / invalidated?
You see, what I plan to do is to use bindings for setting up correct sizes of controls at runtime, depending on current screen-resolution.
Therefore it would be great to know when a part or all of the visual tree is being redrawn, so that I can re-calculate the bound values and mark them as changed at that time.
I can solve it by polling the current screen resolution in Unity, but it feels like a hack, especially if there's a cleaner solution.
If there's actually support for converters I'll probably use those instead of bindings.
And one last thing; is there some automated way to hook each xaml-control with a certain class to an individual instance of a [Noesis.Extended]-class in Unity that has the same class-name?
Sort of like code-behind?
I know that I can use SetDataContext to make that connection, but if there's a way to do it without manually looping through or searching for controls in the visual tree when entering play-mode that would be super.
All of these questions come from a wish to find the best and most effective way to use Noesis in Unity for semi-large to large enterprise applications. I love the freedom and lack of clutter that Noesis brings to the table, and I don't want to miss out on something just because I haven't managed to find the correct documentation.
Best regards,
Anders
-
-
sfernandez
Site Admin
- Posts: 2908
- Joined:
Re: General questions about bindings, converters etc.
Hi,
As you find out looking at the documentation, ValueConverters are only available in C++ right now. But we have plans to add support for ValueConverters in Unity soon.
DependencyObject derived classes are notified when a Dependency Property changes. You can extend an element, place it in the tree, and monitor changes to ActualWidth/ActualHeight properties, that are updated when layout process changes the size of any element.
To resolve named elements to code-behind member variables, you can use the PostInit function, that is called after xaml gets loaded:
As I said before, you can extend any class that inherits from FrameworkElement (a Panel, a Control, a Shape, ...) and reference it directly in the xaml file.
Do not hesitate to ask any doubt you have here in the forums. Other people can benefit from the things we talk here
Kind regards,
- Sergio
As you find out looking at the documentation, ValueConverters are only available in C++ right now. But we have plans to add support for ValueConverters in Unity soon.
DependencyObject derived classes are notified when a Dependency Property changes. You can extend an element, place it in the tree, and monitor changes to ActualWidth/ActualHeight properties, that are updated when layout process changes the size of any element.
Code: Select all
namespace MyNamespace
{
[Noesis.Extended]
public class MyGrid : Grid
{
// ...
public void DependencyPropertyChanged(DependencyProperty dp)
{
if (dp == FrameworkElement.ActualWidthProperty || dp == FrameworkElement.ActualHeightProperty)
{
// ...
}
}
// ...
}
}
Code: Select all
namespace MyNamespace
{
[Noesis.Extended]
public class MyGrid : Grid
{
// ...
private Noesis.Rectangle _rect;
public void OnPostInit()
{
this._rect = FindName<Noesis.Rectangle>("rect");
if (this._rect != null)
{
// ...
}
}
// ...
}
}
Code: Select all
<!-- You can specify your extended class... -->
<Grid
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:custom="clr-namespace:MyNamespace"
x:Class="MyNamespace.MyGrid"> <!-- ... as root of the xaml, or... -->
<!-- ... inside any container -->
<custom:MyGrid />
<Rectangle x:Name="rect" Fill="Red" Width="100" Height="50"/>
</Grid>

Kind regards,
- Sergio
Re: General questions about bindings, converters etc.
We have plans for auto generating code behind in Unity. It is one of the new things, among a lot of new features, we are adding in noesisGUI v1.2. As soon as there is a beta we will announce it here.And one last thing; is there some automated way to hook each xaml-control with a certain class to an individual instance of a [Noesis.Extended]-class in Unity that has the same class-name?
Sort of like code-behind?
I know that I can use SetDataContext to make that connection, but if there's a way to do it without manually looping through or searching for controls in the visual tree when entering play-mode that would be super.
Re: General questions about bindings, converters etc.
Thank you both! Your suggestions are great, I had a feeling there was functionality that I didn't know about yet.
And I will keep an eye out for the beta release!
Best regards,
Anders
And I will keep an eye out for the beta release!
Best regards,
Anders
Who is online
Users browsing this forum: No registered users and 10 guests