Hello,
I continue to work on my popup window who is done by a user control, i try to acheive a binding to my title label and a description text block. I did a test by finding the component in the xaml with findname. It work just fine. But i wan't to understand binding data and i try to do with notifyproperchanged but it does nothing i have no error but i still havn't got any text on my popup. I give you my little test to show.
my usercontrol
using Noesis;
using System;
using UnityEngine;
[Noesis.Extended]
[Noesis.UserControlSource("Assets/xaml_GUI/PopUp.xaml")]
public class PopUpControl : Noesis.UserControl
{
//try to binding
private string _title;
public String Title
{
get { return _title; }
set {
if (_title != value)
{
_title = value;
NotifyPropertyChanged("Title");
}
}
}
#region value
Storyboard Appearanim;
Grid grid;
Label TitleLabel;
TextBlock DescriptionText;
#endregion
public void OnPostInit()
{
grid = FindName<Grid>("grid");//grid pour l'anim de la popup
Appearanim = FindName<Storyboard>("AppearStoryBoard");
TitleLabel = FindName<Label>("Title");
DescriptionText = FindName<TextBlock>("Description");
Button closBtn = FindName<Button>("Close");//button de fermeture de la popup
closBtn.Click += OnbtnClick;
}
#region callback
void OnbtnClick(BaseComponent sender, RoutedEventArgs args)
{
Debug.Log("Hide popup");
SetVisibility(Visibility.Hidden);
}//callback click
#endregion
#region Function
public void ShowPopup()
{
SetVisibility(Visibility.Visible);
if(Appearanim != null)
Appearanim.Begin(this.grid);
}//montre la popup avec storyboard
//Hard Do this is working!!!
public void SetTitle(string _s)
{
TitleLabel.SetContent(_s);
}
public void SetDescription(string _s)
{
DescriptionText.SetText(_s);
}
#endregion
}
my xaml
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="PopUpControl"
x:Name="UserControl"
d:DesignWidth="640" d:DesignHeight="480" Width="1024" Height="768">
<UserControl.Resources>
<Storyboard x:Key="AppearStoryBoard" x:Name="AppearStoryBoard">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0" Value="-0.052"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<ElasticEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0" Value="0.052"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<ElasticEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<ElasticEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<ElasticEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Style x:Key="CloseBtn" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="ellipse">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<RadialGradientBrush>
<GradientStop Color="#FF057FB8" Offset="0"/>
<GradientStop Color="#009ADFFF" Offset="1"/>
</RadialGradientBrush>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="ellipse" HorizontalAlignment="Left" Height="56" VerticalAlignment="Top" Width="56" Fill="#00000000"/>
<Path Data="M22.6665,0 L33.3335,0 33.3335,22.6665 56,22.6665 56,33.3335 33.3335,33.3335 33.3335,56 22.6665,56 22.6665,33.3335 0,33.3335 0,22.6665 22.6665,22.6665 z" RenderTransformOrigin="0.500000001634869,0.5" Stretch="Fill">
<Path.Fill>
<LinearGradientBrush StartPoint="0.5,0" MappingMode="RelativeToBoundingBox" EndPoint="0.5,1">
<GradientStop Color="#FF5B0000" Offset="1"/>
<GradientStop Color="#FFB80000"/>
</LinearGradientBrush>
</Path.Fill>
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-45"/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
<Path Data="M22.666501,51.087759 L33.3335,51.087759 33.3335,51.309045 22.666501,51.309045 z M22.666501,42.60283 L33.3335,42.60283 33.3335,46.087759 22.666501,46.087759 z M22.666501,33.940774 L33.3335,33.940774 33.3335,37.60283 22.666501,37.60283 z M0,25.101938 L56,25.101938 56,28.642545 33.3335,28.642545 33.3335,28.940774 22.666501,28.940774 22.666501,28.642545 0,28.642545 z M22.666501,16.43988 L33.3335,16.43988 33.3335,17.975545 56,17.975545 56,20.101938 0,20.101938 0,17.975545 22.666501,17.975545 z M22.666501,8.3081527 L33.3335,8.3081527 33.3335,11.43988 22.666501,11.43988 z M22.666501,0 L33.3335,0 33.3335,3.3081522 22.666501,3.3081522 z" Margin="0,4.691,0,0" RenderTransformOrigin="0.500000005518652,0.454287254260614" Stretch="Fill" Fill="#1DFFFFFF">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-45"/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True"/>
<Trigger Property="IsDefaulted" Value="True"/>
<Trigger Property="IsMouseOver" Value="True"/>
<Trigger Property="IsPressed" Value="True"/>
<Trigger Property="IsEnabled" Value="False"/>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource AppearStoryBoard}"/>
</EventTrigger>
</UserControl.Triggers>
<Grid x:Name="LayoutRoot" Width="1024" Height="768" HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid x:Name="grid" HorizontalAlignment="Left" Height="748" VerticalAlignment="Top" Width="1004" Margin="20,10,0,0" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Grid.RenderTransform>
<Rectangle x:Name="rectangle" Height="460" Width="620" RadiusY="19" RadiusX="19" RenderTransformOrigin="0.5,0.5">
<Rectangle.Stroke>
<ImageBrush/>
</Rectangle.Stroke>
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
<Rectangle.Fill>
<ImageBrush ImageSource="/UnityGUI_Blend;component/pathwork01.jpg" TileMode="Tile" Stretch="UniformToFill" Opacity="0.155">
<ImageBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform CenterY="0.5" CenterX="0.5" ScaleY="-1" ScaleX="-0.3"/>
<SkewTransform CenterY="0.5" CenterX="0.5"/>
<RotateTransform CenterY="0.5" CenterX="0.5" Angle="45"/>
<TranslateTransform/>
</TransformGroup>
</ImageBrush.RelativeTransform>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
<Button x:Name="Close" Content="Button" HorizontalAlignment="Left" Height="56" Margin="745.666,153,0,0" Style="{DynamicResource CloseBtn}" VerticalAlignment="Top" Width="56" RenderTransformOrigin="0.5,0.5">
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Button.RenderTransform>
</Button>
<Label x:Name="Title" Content="{Binding PopUpControl.Title}" HorizontalAlignment="Left" Height="33.333" Margin="221.334,153,0,0" VerticalAlignment="Top" Width="505.334" FontSize="21.333"/>
<TextBlock x:Name="Description" HorizontalAlignment="Left" Height="184" Margin="221.334,202.667,0,0" TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Top" Width="388"/>
</Grid>
</Grid>
</UserControl>
the call
popup = new PopUpControl();
root.FindName<Grid>("Main").GetChildren().Add(popup);
popup.Title = "bonjour";//doesn't work
popup.SetDescription("Here the description of the Product");//work
I'm pretty shure i missing some thing but i can't see what

!
Thanks