jeroenvdv
Topic Author
Posts: 13
Joined: 15 Sep 2014, 20:21

DataTriggers & UpdateSourceTrigger

11 Oct 2014, 19:12

Hi guys (and girls),

I'm a new user of NoesisGUI for Unity, to do UI development for a (non-game) application.

NoesisGUI gives great opportunities for designing XAML seperate from the application itself. However, I'm missing some (essential) features to be able to really seperate UI and engine/scripts.

First of all, DataTriggers. For example, to automatically draw a border around a listbox-item when that "cue" is "running" (that's seperate from the selected item). That's something that should really be possible from just the XAML with binding to a DataTrigger, instead of diving into code.

Second, UpdateSourceTrigger. I think in most cases, a textbox should "validate" (bind) not when typing a character, but when losing focus. That's easy via the UpdateSourceTrigger. Could we get that in NoesisGUI for Unity please?

However, thanks for creating & supporting such a great product. Keep it up!
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: DataTriggers & UpdateSourceTrigger

13 Oct 2014, 18:24

Hi,

You are right, DataTriggers are very very useful and that's why we want to incorporate them in one of the following releases. Meanwhile the scenario you exposed should be done exposing Visibility properties in the DataContext to hide/show parts of the DataTemplate depending on the state of your data item.

You will be glad to hear that UpdateSourceTrigger is implemented, but it seems that default UpdateSourceTrigger is not correctly set in the TextBox.Text property, it should be set to LostFocus. We will fix it for the next release, thanks for pointing it out.
 
jeroenvdv
Topic Author
Posts: 13
Joined: 15 Sep 2014, 20:21

Re: DataTriggers & UpdateSourceTrigger

13 Oct 2014, 23:21

Thanks for the quick reply!

To use the visibility property binding to a bool, I need a boolToVisibility converter. As far as I can find, converters are not available in Noesis for Unity3D (yet)..

For the UpdateSourceTrigger ; great to hear it's coming. And having lostfocus as default for a textbox sounds logical to me. Thanks again!

Jeroen
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: DataTriggers & UpdateSourceTrigger

14 Oct 2014, 01:35

What I mean about the visibility is to expose in the ViewModel a property of type Visibility synchronized with the bool:
public class ViewModel : Noesis.BaseComponent
{
    private bool _isRunning = false;
    public bool IsRunning
    {
        get { return _isRunning; }
        set
        {
            _isRunning = value;
            ShowCue = (value ? Noesis.Visibility.Visible : Noesis.Visibility.Hidden); 
        }
    }

    public Noesis.Visibility ShowCue { get; private set; }

    // ...
}
Then bind the visibility of the Cue representation in the DataTemplate with that property:
<DataTemplate>
    <Grid>
        <Rectangle Stroke="Red" Margin="-1" Visibility="{Binding ShowCue}"/>
        <TextBlock Text="{Binding Name}"/>
    </Grid>
</DataTemplate>
---

And the other issue, you can already use the UpdateSourceTrigger.LostFocus, but as I mentioned it is not correctly initialized in the TextBox, so you need to specify it manually:
<TextBox Text="{Binding Login, UpdateSourceTrigger=LostFocus}"/>
 
User avatar
ai_enabled
Posts: 221
Joined: 18 Jul 2013, 05:28
Contact:

Re: DataTriggers & UpdateSourceTrigger

04 Feb 2015, 04:49

I'm really missing DataTrigger feature in NoesisGUI, as I can't implement changing ContentTemplate without DataTrigger and need to use sophisticated workarounds. Hope you can bring it in the future release (I mean after 1.2)!
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
User avatar
jsantos
Site Admin
Posts: 2904
Joined: 20 Jan 2012, 17:18
Contact:

Re: DataTriggers & UpdateSourceTrigger

06 Feb 2015, 18:11

Yes, DataTriggers are in the list of imminent features to be implemented after v1.2.0
 
walhore
Posts: 19
Joined: 25 Feb 2013, 17:24

Re: DataTriggers & UpdateSourceTrigger

02 Mar 2015, 18:38

Congratulations on 1.2! Can't wait to start using it!

Absolutely would love to see data triggers in a soon to be release! In the meantime, can you suggest a clean XAML only approach for doing messaging/prompts (a user rolls over a button or clicks and a message somewhere else on the screen appears to tell them what it is and what it does; not tool tips). Pretty straight forward and was thinking data triggers would be a nice solution, but... ;)
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: DataTriggers & UpdateSourceTrigger

04 Mar 2015, 11:03

Thanks :)

I don't know if I understood correctly the scenario you want, but I have created this:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <Storyboard x:Key="showHi">
            <DoubleAnimation Duration="0:0:0.3" To="0" Storyboard.TargetName="hiMsg" Storyboard.TargetProperty="RenderTransform.Y"/>
            <DoubleAnimation Duration="0:0:0.3" To="1" Storyboard.TargetName="hiMsg" Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
        <Storyboard x:Key="hideHi">
            <DoubleAnimation Duration="0:0:0.3" To="-100" Storyboard.TargetName="hiMsg" Storyboard.TargetProperty="RenderTransform.Y"/>
            <DoubleAnimation Duration="0:0:0.3" To="0" Storyboard.TargetName="hiMsg" Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
        <Storyboard x:Key="showBye">
            <DoubleAnimation Duration="0:0:0.3" To="0" Storyboard.TargetName="byeMsg" Storyboard.TargetProperty="RenderTransform.Y"/>
            <DoubleAnimation Duration="0:0:0.3" To="1" Storyboard.TargetName="byeMsg" Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
        <Storyboard x:Key="hideBye">
            <DoubleAnimation Duration="0:0:0.3" To="-100" Storyboard.TargetName="byeMsg" Storyboard.TargetProperty="RenderTransform.Y"/>
            <DoubleAnimation Duration="0:0:0.3" To="0" Storyboard.TargetName="byeMsg" Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
    </Grid.Resources>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
        <Border x:Name="hiMsg" BorderBrush="Black" BorderThickness="1" Background="Silver" Padding="50,20">
            <Border.RenderTransform>
                <TranslateTransform Y="-100"/>
            </Border.RenderTransform>
            <TextBlock Text="Hi" Foreground="Black" FontSize="20"/>
        </Border>
        <Border x:Name="byeMsg" BorderBrush="Black" BorderThickness="1" Background="Silver" Padding="50,20">
            <Border.RenderTransform>
                <TranslateTransform Y="-100"/>
            </Border.RenderTransform>
            <TextBlock Text="Bye" Foreground="Black" FontSize="20"/>
        </Border>
    </StackPanel>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="5">
        <Button Content="Say Hi" Padding="20,0">
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource hideBye}"/>
                        <BeginStoryboard Storyboard="{StaticResource showHi}"/>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Button.Triggers>
        </Button>
        <Button Content="Say Bye" Padding="20,0">
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource hideHi}"/>
                        <BeginStoryboard Storyboard="{StaticResource showBye}"/>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Button.Triggers>
        </Button>
    </StackPanel>
</Grid>

Who is online

Users browsing this forum: No registered users and 0 guests