Some questions with working with Noesis [Unity]
I have had the last few weeks messing with Noesis GUI and have learned many things along the way
and while I have learned several aspects of creating a GUI and working with XAML
I am left with some questions that don't really get explained in the documentation
I am using Unity 2018
I am building Xaml by code because working with blend hasn't been useful or intuitive
my first question is
how would I best update the GUI? removing or adding elements on demand or public calls?
say if a user logs into the online profile, could I tag elements for a name and find it later?
or can I navigate the tree and delete the element despite its original reference in a separate function?
for example;
also, I have been having trouble with margins cropping content, I assume this is mostly on my fault for not working with Visual Blender.
I haven't found a way to use padding on panels, or what panels support padding, however, I would find it useful if I could see the grid lines
but I haven't found how to create them programmatically as of yet
and while I have learned several aspects of creating a GUI and working with XAML
I am left with some questions that don't really get explained in the documentation
I am using Unity 2018
I am building Xaml by code because working with blend hasn't been useful or intuitive
my first question is
how would I best update the GUI? removing or adding elements on demand or public calls?
say if a user logs into the online profile, could I tag elements for a name and find it later?
or can I navigate the tree and delete the element despite its original reference in a separate function?
for example;
Code: Select all
Root = (Noesis.Grid)GetComponent<NoesisView>().view.Content;
public void UpdateGUI(){
Root.Children.Add(Login())
}
private DockPanel Login(){
_result = new Noesis.Grid();
return _result;
}
I haven't found a way to use padding on panels, or what panels support padding, however, I would find it useful if I could see the grid lines
but I haven't found how to create them programmatically as of yet
<Grid Background="Gray" ShowGridLines="True">
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Some questions with working with Noesis [Unity]
NoesisGUI offers (almost) the same API as WPF (Windows Presentation Foundation), that includes a lot of controls with its own ways of dealing with content depending on the exposed functionality. To get a basic understanding on the different UI elements and how to work with them you can read Layout and Panels tutorial. All the properties you can set in xaml are the same ones you can set in code, so for example:how would I best update the GUI? removing or adding elements on demand or public calls?
Code: Select all
<Expander Header="Some Header" Content="Some Content"/>
Code: Select all
Expander expander = new Expander();
expander.Header = "Some Header";
expander.Content = "Some Content";
If you can't keep references to the elements, you can register them by name. This is possible because all UI trees have a NameScope object in the root where you can store named references.say if a user logs into the online profile, could I tag elements for a name and find it later?
In xaml this is done using the x:Name property, but in code you have to manually call RegisterName (and UnregisterName when removed):
Code: Select all
<<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel x:Name="panel">
<TextBlock Text="Hello World!"/>
<Button x:Name="btn" Content="Button"/>
</StackPanel>
</Grid>
Code: Select all
StackPanel stackPanel = new StackPanel();
m_root.Children.Add(stackPanel);
m_root.RegisterName("panel", stackPanel);
TextBlock textBlock = new TextBlock { Text = "Hello World!" };
stackPanel.Children.Add(textBlock);
Button button = new Button { Content = "Button" };
stackPanel.Children.Add(button);
stackPanel.RegisterName("btn", button);
Code: Select all
// ...
StackPanel panel = (StackPanel)m_root.FindName("panel");
Button btn = (Button)m_root.FindName("btn");
panel.Children.Remove(btn);
panel.UnregisterName("btn");
As I said above each element and control exposes different properties depending on what they do and how they layout content.I have been having trouble with margins cropping content
Margin property is defined in FrameworkElement, so all derived classes can use it.
Padding property is defined in Border and Control, so all derived classes can use it. A Panel (like Grid, StackPanel, Canvas...) inherit from FrameworkElement, so they cannot use the Padding property. You have to use margin in children to achieve what you want.
ShowGridLines property is not implemented but you can just see how a Grid is organized by adding a colored Rectangle in each cell:I would find it useful if I could see the grid lines but I haven't found how to create them programmatically as of yet
Code: Select all
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="Red"/>
<Rectangle Grid.Column="1" Fill="Green"/>
<Rectangle Grid.Column="2" Fill="Blue"/>
<!-- ... rest of elements -->
</Grid>
Re: Some questions with working with Noesis [Unity]
Thanks for the response! this answers a lot of the questions I've been looking for
Who is online
Users browsing this forum: Google [Bot] and 80 guests