These are chat archives for AvaloniaUI/Avalonia

24th
Mar 2016
danwalmsley
@danwalmsley
Mar 24 2016 12:22
@grokys you there?
Steven Kirk
@grokys
Mar 24 2016 12:23
i am
danwalmsley
@danwalmsley
Mar 24 2016 12:25
I'm trying to implement my tooltip as a behavior
iv got a simple bit of code so far
  [ContentProperty("Content")]
    public class PopupBehavior : Behavior<Control>
    {
        private DispatcherTimer timer;
        private Popup popup;        

        public PopupBehavior()
        {
            timer = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 0, 500);
            timer.Tick += Timer_Tick;            

            popup = new Popup
            {
                PlacementMode = PlacementMode.Pointer,
                Width = 100,
                Height = 100,                                
                Child = Content
            };            

            ContentProperty.Changed.Subscribe((o) =>
            {
                popup.Child = o.NewValue as Control;
            });
        }

        public static readonly PerspexProperty ContentProperty = PerspexProperty.Register<PopupBehavior, Control>(nameof(Content));

        public Control Content
        {
            get { return (Control)GetValue(ContentProperty); }
            set { SetValue(ContentProperty, value); }
        }

        protected override void OnAttached()
        {
            AssociatedObject.PointerEnter += AssociatedObject_PointerEnter;
            AssociatedObject.PointerLeave += AssociatedObject_PointerLeave;
            AssociatedObject.PointerMoved += AssociatedObject_PointerMoved;
        }

        protected override void OnDetaching()
        {
            AssociatedObject.PointerEnter -= AssociatedObject_PointerEnter;
            AssociatedObject.PointerLeave -= AssociatedObject_PointerLeave;
            AssociatedObject.PointerMoved -= AssociatedObject_PointerMoved;
        }        

        private void AssociatedObject_PointerMoved(object sender, PointerEventArgs e)
        {
            if (popup.IsOpen)
            {
                if(!popup.IsPointerOver)
                {
                    //Console.WriteLine(e.GetPosition(popup));                    
                }
            }
            else
            { 
                timer.Stop();
                timer.Start();
            }
        }

        private void AssociatedObject_PointerLeave(object sender, PointerEventArgs e)
        {
           // throw new NotImplementedException();
        }

        private void AssociatedObject_PointerEnter(object sender, PointerEventArgs e)
        {
            //throw new NotImplementedException();
        }        

        private void Timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();

            OnBeforePopupOpen();

            popup.Open();      
        }

        /// <summary>
        /// Method is called before popup opens to retrieve data and cancel popup open if required.
        /// </summary>
        /// <returns>true if the popup will open, false if it wont.</returns>
        public virtual bool OnBeforePopupOpen()
        {
            return true;
        }
    }
so I'm creating a popup control
to contain the tooltip....
but when I try to do in AssociatedObject_PointerEnter
getposition it throws exception
because the popup is not in the visual tree
how do I add my popup to visual tree?
Alexey
@flcl42
Mar 24 2016 12:29
Didn't someone think about build perspex for chrome nacl?
Steven Kirk
@grokys
Mar 24 2016 12:32
@danwalmsley try setting the Popup's PlacementTarget
that should give it an anchor into the visual tree
@flcl42 not that i'm aware of!
danwalmsley
@danwalmsley
Mar 24 2016 12:35
            ContentProperty.Changed.Subscribe((o) =>
            {
                popup.Child = o.NewValue as Control;
                popup.PlacementTarget = AssociatedObject;
            });
I did that... but still get the error
AssociatedObject comes from behaviour class, and I checked it is the TextEditor control it should be
is there a way to manually attach?
Steven Kirk
@grokys
Mar 24 2016 12:43
manually attaching the popup to the visual tree isn't the right way to solve it
it's kinda possible but a massive hack
that line takes the PlacementTarget to try to work out how to get the position
so it should work if the PlacementTarget is in the visual tree
danwalmsley
@danwalmsley
Mar 24 2016 12:45
private void AssociatedObject_PointerMoved(object sender, PointerEventArgs e)
        {
            if (popup.IsOpen)
            {
                if(!popup.IsPointerOver)
                { 
                    Console.WriteLine(e.GetPosition(popup));                    
                }
            }
            else
            { 
                timer.Stop();
                timer.Start();
            }
        }
that e.GetPosition is the bit that fails
placement target is set however
but popup isn't a child of PlacementTarget
as far as I can tell
which I why I cant get mouse co-ordinates relative to the popup?
Steven Kirk
@grokys
Mar 24 2016 12:46
i'm confused - why are you trying to get the position of the popup? you've already said the popup isn't in the visual tree
danwalmsley
@danwalmsley
Mar 24 2016 12:47
I'm trying to see how far the mouse is from the popup
Steven Kirk
@grokys
Mar 24 2016 12:47
bu the popup isn't on the visual tree so it doesn't have a position
danwalmsley
@danwalmsley
Mar 24 2016 12:47
I want it to only close when the mouse gets a certain distance from the popup
ah ok
so it wouldn't be possible then?
Steven Kirk
@grokys
Mar 24 2016 12:48
yeah, it's possible i think
but you're misunderstanding how popup works
Popup works like in WPF - it's a control that you can place in e.g. your XAML that will open a PopupRoot.
the PopupRoot is the actual popup window
you can get to that using the Popup.Root property
danwalmsley
@danwalmsley
Mar 24 2016 12:50
ah ok so its a separate window with its own visual tree then
Steven Kirk
@grokys
Mar 24 2016 12:50
yeah, of course
in the example above, Popup is added to a Grid - so it's a visual child of Grid. but Popup itself is invisible
danwalmsley
@danwalmsley
Mar 24 2016 12:52
I'm thinking trying to see how far mouse moves away from popup is wrong thing for me to do
Steven Kirk
@grokys
Mar 24 2016 12:52
but when it opens, it creates a PopupRoot to display the content
danwalmsley
@danwalmsley
Mar 24 2016 12:52
I just need to see if mouse moves away from the position the popup opened
ah the difference in my case
<te:TextEditor Name="editor" Grid.Row="1" TextDocument="{Binding TextDocument, Mode=TwoWay}"
                     FontFamily="{Binding FontFamily}" FontSize="14" Foreground="#D4D4D4" BorderThickness="0"
                     BeforeTextChangedCommand="{Binding BeforeTextChangedCommand}"
                     TextChangedCommand="{Binding TextChangedCommand}"
                     TextChangedDelay="225" CaretIndex="{Binding CaretIndex}" VerticalAlignment="Stretch"
                     AcceptsReturn="true" AcceptsTab="true" TabCharacter="{Binding TabCharacter}"
                     CaretLocationInTextView="{Binding CaretLocation}" SelectedWord="{Binding WordAtCaret}"
                     LineHeight="{Binding LineHeight}" BackgroundRenderers="{Binding BackgroundRenderers}" DocumentLineTransformers="{Binding DocumentLineTransformers}" Margins="{Binding Margins}"
                     MouseCursorOffset="{Binding MouseCursorOffset, Mode=TwoWay}">

        <i:Interaction.Behaviors>
          <behaviours:PopupBehavior>            
              <Grid Background="Red">
                <TextBlock Text="From popup behavior" Foreground="White" />
              </Grid>                          
          </behaviours:PopupBehavior>
        </i:Interaction.Behaviors>
my popup behaviour is a visual child?
but the popup isnt
Steven Kirk
@grokys
Mar 24 2016 12:53
can't you use perspex's Tooltip?
no, behaviors aren't part of the visual tree
danwalmsley
@danwalmsley
Mar 24 2016 12:54
its because with tooltip I don't have a way to find out what line, col of text its going to open on
then query for data to fill the tooltip
before it opens
Steven Kirk
@grokys
Mar 24 2016 12:54
ah ok
yeah, that should probably be something that Tooltip can handle
danwalmsley
@danwalmsley
Mar 24 2016 12:55
in my tooltip behaviour I was going to do something like this
  private void Timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();

            OnBeforePopupOpen();

            popup.Open();      
        }
that onBeforepopup open would allow me to retrieve data and update view models before it opens
but its still not a great solution
If you know a better way I could add it to existing tooltip and do a PR
Steven Kirk
@grokys
Mar 24 2016 12:57
yeah, i'm trying to think of a nice MVVM friendly way of doing it...
maybe... <Control ToolTip.Tip="{Binding ToolTip}" ToolTip.BeforeOpen="{Binding UpdateToolTipCommand}"/>
danwalmsley
@danwalmsley
Mar 24 2016 12:59
I also need the UpdateToolTipCommand to be able to cancel the Open
incase no valid data is found to be displayed
Steven Kirk
@grokys
Mar 24 2016 12:59
hmm
danwalmsley
@danwalmsley
Mar 24 2016 12:59
and I need to be able to get tooltip to close when mouse moves again
Steven Kirk
@grokys
Mar 24 2016 12:59
that should already happen, no?
danwalmsley
@danwalmsley
Mar 24 2016 13:00
(It should look and work like when you hover over a method name in visual studio and it shows you info on that method)
no you have to click outside the tooltip for it to close
I'm happy to do the work to implement all this
I just don't know a good solution
Steven Kirk
@grokys
Mar 24 2016 13:01
well that sounds like a bug in ToolTip if you have to click outside it
but you might be right that this is a little bit too specialized for the perspex ToolTip
i'd advise looking at it's code though for your implementation!
danwalmsley
@danwalmsley
Mar 24 2016 13:07
yeh will do, probably I'll make my own tooltip based on that then
Steven Kirk
@grokys
Mar 24 2016 13:09
that's not a behavior, it's just a simple attached property
but the idea should be very similar
danwalmsley
@danwalmsley
Mar 24 2016 13:10
do you think its a good use for a behaviour?
Steven Kirk
@grokys
Mar 24 2016 13:16
tbh i'm not sure what advantages behaviours give over attached properties in perspex - i've not really investigated
i'm sure @wieslawsoltes could tell you
Darnell Williams
@Seeker1437
Mar 24 2016 13:29
@danwalmsley I feel like the thing vs has is just another line adorner
much like how you handle the active line coloring and the breakpoint stuff
That it might me custom built as anotjer object lile that.
On top of that, the control you get is actually still a tooltip, just extended implementation
danwalmsley
@danwalmsley
Mar 24 2016 13:40
@Seeker1437 yeh I'm coming round to that idea now
Steven Kirk
@grokys
Mar 24 2016 13:50
i think VS uses a popup - the tooltip can extend outside of the VS window
danwalmsley
@danwalmsley
Mar 24 2016 13:51
@grokys was that last bug you fixed for @wieslawsoltes to do with datacontext not getting set inside behaviors?
I have a control inside a behavior
with its datacontext bound to a property in viewmodel
but in debugger data context ends up being null
2 secs I'll show the xaml
I updated to latest nugget... but loads of things have broken
danwalmsley
@danwalmsley
Mar 24 2016 13:59
ok il give details tonight
@danwalmsley I did not try to consume DataContext inside behaviors when control are involved
                    <Button x:Name="moveRightButton" Content="Move Right" Grid.Row="1" Grid.Column="4" Margin="0,0,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <i:Interaction.Behaviors>
                            <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #moveRightButton}">
                                <ia:InvokeCommandAction Command="{Binding MoveRightCommand}"/>
                            </ia:EventTriggerBehavior>
                        </i:Interaction.Behaviors>
                    </Button>
danwalmsley
@danwalmsley
Mar 24 2016 14:00
@wieslawsoltes I wasn't on latest nuget so will try later when I can get that to work
I have something akin to this
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 14:00
@danwalmsley Regarding the popup and behaviors, I did try to do something similar and had same problems
danwalmsley
@danwalmsley
Mar 24 2016 14:01
<i:Interaction.Behaviors>
                            <ia:PopupBehavior>
                                            <Control DataContext={Binding aaa} />
                            </ia:PopupBehavior>
                        </i:Interaction.Behaviors>
Datacontext is not getting set
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 14:01
anyway this actually works, but Child is created inside behavior and not received from xaml https://github.com/XamlBehaviors/XamlBehaviors/blob/master/samples/XamlTestApplicationPcl/Actions/PopupAction.cs
danwalmsley
@danwalmsley
Mar 24 2016 14:02
@wieslawsoltes I started off with your popup action
but then migrated it to a behavior
so I could get child from xaml
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 14:02
yes I get want you want to achieve here

Datacontext is not getting set

@danwalmsley This is different, I do not do this in my sample app

danwalmsley
@danwalmsley
Mar 24 2016 14:04
ok
I'll have to come back to this later
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 14:04
But I did run sometime ago into similar issue
danwalmsley
@danwalmsley
Mar 24 2016 14:05
il create an issue and a repro
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 14:05
Did you check if setting DataContext works outside behaviors?
Darnell Williams
@Seeker1437
Mar 24 2016 14:26
FOr the TabControl, can I bind the headerSelector to a PerspexProperty?
im confused on how it works
Steven Kirk
@grokys
Mar 24 2016 14:30
don't worry about the HeaderSelector - that's an internal detail
just create TabItems in the same way you do for WPF
without more info that's the only advice i can give ;)
Denis Zaporozhets
@QuantumDeveloper
Mar 24 2016 14:33
@grokys hi. Nothing heared from that guy in MS?
Steven Kirk
@grokys
Mar 24 2016 14:33
no, not yet :(
Denis Zaporozhets
@QuantumDeveloper
Mar 24 2016 14:33
heh
Steven Kirk
@grokys
Mar 24 2016 14:33
maybe he's busy preparing for build?
maybe they'll announce something ;)
Denis Zaporozhets
@QuantumDeveloper
Mar 24 2016 14:33
will see)
Darnell Williams
@Seeker1437
Mar 24 2016 14:37

@grokys the DockControl inherits TabControl

the DockControl contains a DockItemsControl which is used to house DockItems

When DockItems are added to the DockItemsControl, the DockControl will display the HeaderContentMemberPath in the thumb and the DockItem Content on the content area

DockItem == TabItem, although DockItem does not inherit from TabItem, I can change that. Right now the DockItem is just a ContentControl
Steven Kirk
@grokys
Mar 24 2016 14:40
if you make it inherit from TabItem can't you just put the content for the tab header in the Header property and the content in the Content property?
have you overridden the ItemContainerGenerator to create DockItems?
Darnell Williams
@Seeker1437
Mar 24 2016 14:41
No
ha I totally forgot that
TabControl is a PITA :(
however making DockItem inherit from TabItem should work i think
Darnell Williams
@Seeker1437
Mar 24 2016 15:03
ill try it lol XD
Steven Kirk
@grokys
Mar 24 2016 15:04
i'm still tempted to remove TabControl - i hate it ;)
my life would be so much easier
if you're still having trouble with it, i'd advise not even using it
just bind a TabStrip to a Carousel and you're done
Darnell Williams
@Seeker1437
Mar 24 2016 15:10
Ha which that change, now the control is invisible XD
with*
Steven Kirk
@grokys
Mar 24 2016 15:17
making DockItem inherit from TabItem? strange
Darnell Williams
@Seeker1437
Mar 24 2016 15:21
I have the original style did you wanna see it, maybe my brain is just not following well XD
<Style Selector="local|DockControl">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid Name="templateRoot" ClipToBounds="True">
            <Grid.ColumnDefinitions>
              <ColumnDefinition />
              <ColumnDefinition Width="0"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto"/>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border Name="contentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="0" Grid.Row="1"
                                    Margin="0 -1 0 0">
              <Grid Name="PART_ItemsHolder" />
            </Border>
            <Grid Margin="0,2,2,0" Name="HeaderContainerGrid">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <ContentControl Grid.Column="0" Name="PrefixContentControl"
                    Content="{TemplateBinding HeaderPrefixContent}"/>
              <local:DockItemsControl
                Name="PART_HeaderItemsControl"
                Grid.Column="1"
                Items="{TemplateBinding Items}"
                ItemsOrganizer="{TemplateBinding HeaderItemsOrganizer}"
                ZIndex="1"/>
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
oops
that might be why too...
wait nvm yeah this si the original template for DockControl
Darnell Williams
@Seeker1437
Mar 24 2016 15:27
ah I left out a part but that doesn't really matter, this is basically the TabStrip though now that I take a closer look

and it basically lets me do something like this:

http://i.imgur.com/tDB3Upl.png

Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 15:35
@danwalmsley
    public class PopupAction : Control, IAction
    {
        public static readonly PerspexProperty ChildProperty =
            PerspexProperty.Register<PopupAction, Control>(nameof(Child));

        [Content]
        public Control Child
        {
            get { return (Control)this.GetValue(PopupAction.ChildProperty); }
            set { this.SetValue(PopupAction.ChildProperty, value); }
        }

        public object Execute(object sender, object parameter)
        {
            new Popup()
            {
                PlacementMode = PlacementMode.Pointer,
                PlacementTarget = sender as Control,
                StaysOpen = false,
                Child = Child ?? new TextBlock
                {
                    Text = "Hello from custom action!",
                    Background = Brushes.Gray
                }
            }.Open();
            return null;
        }
    }
<Button Name="popupButton2" Content="Click Me" HorizontalAlignment="Stretch" Grid.Row="0" Margin="5" VerticalAlignment="Stretch" FontSize="20">
    <i:Interaction.Behaviors>
        <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #popupButton2}">
            <actions:PopupAction>
                <Border DataContext="{Binding #popupButton2}" Background="Yellow" BorderBrush="Red" BorderThickness="1" Padding="5">
                    <TextBlock Text="{Binding Count}" Foreground="Red"/>
                </Border>
            </actions:PopupAction>
        </ia:EventTriggerBehavior>
    </i:Interaction.Behaviors>
</Button>
The popup shows once, on second time throws, binding to DataContext does not work :)
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 15:41
ok this works without exceptions:
    public class PopupAction : PerspexObject, IAction
    {
        public static readonly PerspexProperty ChildProperty =
            PerspexProperty.Register<PopupAction, Control>(nameof(Child));

        [Content]
        public Control Child
        {
            get { return (Control)this.GetValue(PopupAction.ChildProperty); }
            set { this.SetValue(PopupAction.ChildProperty, value); }
        }

        private Popup popup = null;

        public object Execute(object sender, object parameter)
        {
            if (popup == null)
            {
                popup = new Popup()
                {
                    PlacementMode = PlacementMode.Pointer,
                    PlacementTarget = sender as Control,
                    StaysOpen = false
                };
            }
            popup.Child = Child;
            popup.Open();
            return null;
        }
    }
danwalmsley
@danwalmsley
Mar 24 2016 15:48
@wieslawsoltes thanks will try that
@grokys with latest nugget package its crashing
image.png
that's called from TreeItemContainerGenerator
line 80, BindingOperations.Apply
(this is a breaking changes since previous versions)
Steven Kirk
@grokys
Mar 24 2016 15:51
hmm looks like it might have been introduced with the fix for #284
danwalmsley
@danwalmsley
Mar 24 2016 15:51
is it something I need to fix in my code to be compatible with that change?
ah it seems it doesn't like it if treeview items has ItemsSource, null
which is case when there are no children
Darnell Williams
@Seeker1437
Mar 24 2016 15:53
@grokys what is our equivalent of Binding.DoNothing?
Steven Kirk
@grokys
Mar 24 2016 15:54
we don't have one :(
that's the first time i've seen that
danwalmsley
@danwalmsley
Mar 24 2016 15:55
this change looks suspicious
image.png
Darnell Williams
@Seeker1437
Mar 24 2016 15:56
oooh dark theme on Edge?
how to do?
danwalmsley
@danwalmsley
Mar 24 2016 15:56
press
...
image.png
then settings
Darnell Williams
@Seeker1437
Mar 24 2016 15:56
@grokys how it will be used:
using Perspex.Markup;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Perspex.Controls;
using Perspex.Data;
using Perspex.Markup.Xaml.Data;

namespace Mabiavalon
{
    public class DockHeaderSizeConverter : IMultiValueConverter
    {
        public Orientation Orientation { get; set; }

        public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null) throw new ArgumentNullException("values");

            if (values.Count < 2) return Binding.DoNothing;

            var val = values
                .Skip(2)
                .OfType<double>()
                .Where(d => !double.IsInfinity(d) && !double.IsNaN(d))
                .Aggregate(values.OfType<double>().First(), (current, diminish) => current - diminish);

            var maxWidth = values.Take(2).OfType<double>().Min();

            return Math.Min(Math.Max(val, 0), maxWidth);
        }
    }
}
Steven Kirk
@grokys
Mar 24 2016 15:56
ok, try returning PerspexProperty.UnsetValue
Darnell Williams
@Seeker1437
Mar 24 2016 15:57
@danwalmsley thanks! sexy :D
danwalmsley
@danwalmsley
Mar 24 2016 15:57
@Seeker1437 I hope you are calling Edge sexy!
Steven Kirk
@grokys
Mar 24 2016 15:57
haha
Darnell Williams
@Seeker1437
Mar 24 2016 15:58
hahaha XD

@grokys Perspex doesn't support Measure with NaN?

I have a multibinding thatmoight return one

<local:DockItemsControl.MaxWidth>
  <MultiBinding>
    <MultiBinding.Converter>
      <local:DockHeaderSizeConverter Orientation="Horizontal"/>
    </MultiBinding.Converter>
    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Width" />
    <Binding RelativeSource="{RelativeSource Self}" Path="ItemsPresenterWidth" />
    <Binding ElementName="PrefixContentControl" Path="Width" />
    <Binding ElementName="DefaultAddButton" Path="DesiredSize.Width" />
    <Binding ElementName="SuffixContentControl" Path="DesiredSize.Width" />
  </MultiBinding>
</local:DockItemsControl.MaxWidth>
Steven Kirk
@grokys
Mar 24 2016 16:03
you mean does MaxWidth support NaN? i have no idea. does WPF?
@danwalmsley with latest perspex i'm getting another error saying "Property 'CanScrollHorizontally not registered on 'AvalonStudio.TextEditor.TextEditor"
previously that property was erroneously an attached property
danwalmsley
@danwalmsley
Mar 24 2016 16:05
yeh I commented out that line to get rid of that
its TextView.cs
sorry texteditor.cs
line 51
once you get past that one
you need to open a project to trigger error
if you still have sample I sent you that will do it
Steven Kirk
@grokys
Mar 24 2016 16:06
ok. if you want to fix that error, see the changes in TextBox
danwalmsley
@danwalmsley
Mar 24 2016 16:06
ok I'll have a look at that cheers
if you don't have a project
do file->new STM32 Project
that will also trigger
(make sure you don't already have one in C:\AvalonStudio\Projects
Steven Kirk
@grokys
Mar 24 2016 16:08
ok, thanks - yeah i see the error
ok, that should be fixed when CI finishes
danwalmsley
@danwalmsley
Mar 24 2016 16:16
@grokys cheers mate, as a bonus for that you get #484 ;)
Darnell Williams
@Seeker1437
Mar 24 2016 16:20
Steven Kirk
@grokys
Mar 24 2016 16:26
@danwalmsley you mean ctrl+x? ;)
@Seeker1437 there are many of reasons why something isn't visible - first check the IsVisible, Opacity and Bounds properties
then DesiredSize if Bounds is 0,0,0,0
danwalmsley
@danwalmsley
Mar 24 2016 16:27
@grokys oh yeh
Steven Kirk
@grokys
Mar 24 2016 16:28
LGTM, will merge when CI passes
danwalmsley
@danwalmsley
Mar 24 2016 16:29
@grokys can I get you to look at another issue I'm having?
if you pull my current master
Darnell Williams
@Seeker1437
Mar 24 2016 16:29
ooooh bounds and desiredSize okay
those are the issues
danwalmsley
@danwalmsley
Mar 24 2016 16:30
then do file new stm32 project
then open the main.cpp file
then hover mouse over main function
Darnell Williams
@Seeker1437
Mar 24 2016 16:30
Im just going to errm try and use the styling stuff from TabSriptItem and stuff I give at this point
danwalmsley
@danwalmsley
Mar 24 2016 16:30
a big red box appears after 1/2 sec
the box should have datacontext set
(see Editor.paml)
but for some reason its not
because its wrapped in a behaviour
Steven Kirk
@grokys
Mar 24 2016 16:35
ok, i don't have a lot of time to debug it, but my guess is that there's no datacontext ;)
danwalmsley
@danwalmsley
Mar 24 2016 16:36
I get datacontext I move it outside the Behaviour
and its a normal control
Steven Kirk
@grokys
Mar 24 2016 16:36
yeah, because it's in a logical tree
danwalmsley
@danwalmsley
Mar 24 2016 16:36
ah so behaviours datacontext needs binding too?
Steven Kirk
@grokys
Mar 24 2016 16:37
when you say DataContext="{Binding HoverProbe}"
it's trying to bind to HoverProbe.DataContext.HoverProbe
oh sorry, because it's a datacontext binding it's slightly different
it's trying to bind to Grid.DataContext.HoverProbe
but you're not setting Grid.DataContext as far as I can see
(Grid is the parent)
danwalmsley
@danwalmsley
Mar 24 2016 16:39
it should have been inherited
from mainwindow I think
Steven Kirk
@grokys
Mar 24 2016 16:40
nope, things get inherited along the logical tree
the logical tree is things like Panel.Children or Border.Child
Perspex knows nothing about behaviors
so unless something the behavior system is doing, or you are doing, sets the DataContext then it's not going to be set
danwalmsley
@danwalmsley
Mar 24 2016 16:41
right ok I see
Steven Kirk
@grokys
Mar 24 2016 16:42
@wieslawsoltes maybe something could be added to behaviors to make them inherit the DataContext?
try doing DataContext="{Binding #editor.DataContext.HoverProbe}" or something
danwalmsley
@danwalmsley
Mar 24 2016 16:46
that doesn't work either... :(
Steven Kirk
@grokys
Mar 24 2016 16:49
ok, probably @wieslawsoltes needs to help you here because as I say, the behaviors are his stuff
i think i need to work on getting some output messages to appear to help debug bindings
danwalmsley
@danwalmsley
Mar 24 2016 16:53
ok @wieslawsoltes are you available later to look at this?
Steven Kirk
@grokys
Mar 24 2016 16:58
actually i suspect that it's not finding #editor because it's in a different tree
i think the behavior system needs a way to either inherit the data context from where it's attached, or to set it explicitly
you can see here, ToolTip sets the PopupRoot's logical parent to the control that it's being popped up on
that means that the PopupRoot will inherit the DataContext
danwalmsley
@danwalmsley
Mar 24 2016 17:46
@grokys thanks will give that ago
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 17:47
@danwalmsley @grokys Not sure what can be done in behaviors, they are same as in UWP/WPF
And for example this works very well:
                    <Button x:Name="decrementButton" Content="Decrement" Grid.Row="1" Grid.Column="0" Margin="5,0,0,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <i:Interaction.Behaviors>
                            <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #decrementButton}">
                                <ia:CallMethodAction TargetObject="{Binding}" MethodName="DecrementCount"/>
                            </ia:EventTriggerBehavior>
                        </i:Interaction.Behaviors>
                    </Button>
danwalmsley
@danwalmsley
Mar 24 2016 17:48
@wieslawsoltes would datacontext be inherited into behaviours in wpf?
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 17:48
The <ia:CallMethodAction TargetObject="{Binding}" MethodName="DecrementCount"/> is using DataContext from main window
Steven Kirk
@grokys
Mar 24 2016 17:49
yeah, but the difference there is that it's not in a separate tree created by the behavior
danwalmsley
@danwalmsley
Mar 24 2016 17:49
@wieslawsoltes whats difference between an Action and a Behavior?
@grokys that suggests its just my special case where I'm using a popup inside that causes the disruption to the tree
so its in my specific behaviour that it needs fixing?
not a general fix for all behaviors
Steven Kirk
@grokys
Mar 24 2016 17:53
it may be, yes
i honestly haven't used behaviors much so i don't know if it's something that's supported out of the box
danwalmsley
@danwalmsley
Mar 24 2016 17:54
is the plan to merge @wieslawsoltes behaviors into Perspex at some point?
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 17:55
I dont think there is plan for merging
Darnell Williams
@Seeker1437
Mar 24 2016 17:57
Honestly, I think Behaviors should be merged
Well
Actually nah
A seperate but supported library
so I guess where it is is good
danwalmsley
@danwalmsley
Mar 24 2016 17:58
well at least it would be nice if they could come from same nugget package
Darnell Williams
@Seeker1437
Mar 24 2016 17:58
si :D
danwalmsley
@danwalmsley
Mar 24 2016 17:58
so you have Perspex, Perspex.Desktop, etc and Xaml.Behaviours?
Steven Kirk
@grokys
Mar 24 2016 17:58
no plan as yes - i wouldn't be opposed to it, but i don't see a problem with them being a separate library
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 17:59
well they will come from main nuget package source , but for now they need Perspex nightlies to work so no reason to release
Darnell Williams
@Seeker1437
Mar 24 2016 17:59
@grokys I think Im going to go ahead to just roll it custom and not inherit TabControl, though I guess at this point I am looking for pointers on what the WPF one worked like possibly?
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:00

@wieslawsoltes whats difference between an Action and a Behavior?

Well action are used by some behaviors like DataTriggerBehavior and EventTriggerBehavior

Darnell Williams
@Seeker1437
Mar 24 2016 18:01
tyeah way different o me
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:01
they are more like setters
Darnell Williams
@Seeker1437
Mar 24 2016 18:02
cuz you say Actions are to behaviors as Setters are to Styles then?
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:04
I dont think that was good analogy
Darnell Williams
@Seeker1437
Mar 24 2016 18:04
oops Setters to Properties*?
still not good though
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:05
I would say Actions more like substitute for code behind event handlers
Actually they are exactly that
Darnell Williams
@Seeker1437
Mar 24 2016 18:06
Oh are these actions like... the POCO then?
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:06
You can get even event args in execute method
Darnell Williams
@Seeker1437
Mar 24 2016 18:06
Basically public event Action<string> OnTextChanged;kinda deal?
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:06
        public object Execute(object sender, object parameter)
        {
            if (_popup == null)
            {
                _popup = new Popup()
                {
                    PlacementMode = PlacementMode.Pointer,
                    PlacementTarget = sender as Control,
                    StaysOpen = false
                };
            }
            _popup.Child = Child;
            _popup.Open();
            return null;
        }
the object parameter is Perspex.Input.PointerPressedEventArgs when combined with <ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #border}">
and object sender is Perspex.Controls.Border
this is xaml
                    <Border Name="border" Grid.Row="1" Margin="5,0,5,5" Background="{StyleResource GrayBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <i:Interaction.Behaviors>
                            <ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #border}">
                                <actions:PopupAction>
                                    <Border Background="Yellow" BorderBrush="Red" BorderThickness="1" Padding="5">
                                        <TextBlock Text="Hello from xaml!" Foreground="Red"/>
                                    </Border>
                                </actions:PopupAction>
                            </ia:EventTriggerBehavior>
                            <actions:ShowPointerPositionBehavior TargetTextBlock="{Binding #position}"/>
                        </i:Interaction.Behaviors>
                        <TextBlock Text="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20"/>
                    </Border>
Darnell Williams
@Seeker1437
Mar 24 2016 18:08
Oh wow okay
Very cool!
I got a book on Behaviors, but it seemed really complicated
Expert WPF and MVVM techniques or something like that, where it was discussed
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:10
Well I was thinking the same, but during porting I found out that core principle is pretty simple
The magic is in the xaml
Darnell Williams
@Seeker1437
Mar 24 2016 18:13
I should try and learn it again XD
Steven Kirk
@grokys
Mar 24 2016 18:13
well i've got some news! looks like i'm going to be working for github!
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:13
wow congratulations
Darnell Williams
@Seeker1437
Mar 24 2016 18:14
Nice, when I looked at their jobs, I saw stuff I don'tknow
Steven Kirk
@grokys
Mar 24 2016 18:14
:D which is why i've been a bit busy recently - trying to finish off some stuff for my current job while that was coming through
Darnell Williams
@Seeker1437
Mar 24 2016 18:14
nice!
What would you be doing :O
Steven Kirk
@grokys
Mar 24 2016 18:15
not 100% sure but working on the windows team. i think on the VS extension, and maybe github desktop?
Darnell Williams
@Seeker1437
Mar 24 2016 18:15
Nice!
remote fun too right?
Steven Kirk
@grokys
Mar 24 2016 18:15
yeah
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:16
they should migrate Github Windows to Perspex ;)
Steven Kirk
@grokys
Mar 24 2016 18:17
exactly ;) don't think i didn't talk about it in the interviews!
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:17
hehe
That would be huge, I could run it on Linux finally
Steven Kirk
@grokys
Mar 24 2016 18:18
i suspect there's still a long way for perspex to go to get to that stage, but would be interesting to see how far it can get
list virtualization will be the big problem
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:19
yeah 12000 line big
Steven Kirk
@grokys
Mar 24 2016 18:20
hah yeah
Darnell Williams
@Seeker1437
Mar 24 2016 18:20
lol
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 18:24
this is all it takes:
<Grid RowDefinitions="Auto,*">
    <TextBlock Text="Move Pointer" Name="position" Grid.Row="0" Margin="5" Background="{StyleResource GrayBrush}" Foreground="{StyleResource YellowBrush}" FontSize="14" TextAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
    <Border Name="border" Grid.Row="1" Margin="5,0,5,5" Background="{StyleResource GrayBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <i:Interaction.Behaviors>
            <behaviors:ShowPointerPositionBehavior TargetTextBlock="{Binding #position}"/>
            <ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #border}">
                <actions:PopupAction>
                    <Border Background="Yellow" BorderBrush="Red" BorderThickness="1" Padding="5">
                        <TextBlock Text="Hello from xaml!" Foreground="Red"/>
                    </Border>
                </actions:PopupAction>
            </ia:EventTriggerBehavior>
        </i:Interaction.Behaviors>
        <TextBlock Text="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20"/>
    </Border>
</Grid>
Darnell Williams
@Seeker1437
Mar 24 2016 18:29
This is utterly amazing
(to me)
@grokys what kind of control allows for HorizontalContentAlightment?
danwalmsley
@danwalmsley
Mar 24 2016 18:34
@grokys iv definitely found a serious bug in Perspex co-ordinate system
its been there a while I think
check this out
image.png
see the coordinates printed in the console window (pretty close to 0,0)
they are printed when textteditor.onpointermoved
that's what the coordinates come out as when the main Perspex window is in the very top left of screen
but if I move the window
...
image.png
look at the coordinates now
... the code that gets the coordinates
protected override void OnPointerMoved(PointerEventArgs e)
        {
            var point = e.GetPosition(textView.TextSurface);

            Console.WriteLine(point.ToString());
congratulations on the GitHub news btw ;)
this coordinates issue is why its taken me so long to realise whats going on with my datacontext, once id set parent, it still wasn't working
and its because it wasn't retrieving data for the correct coordinates.
danwalmsley
@danwalmsley
Mar 24 2016 18:45
its obviously subtracting the windows topLeft position before returning the results, any ideas where I need to look in Perspex code?
danwalmsley
@danwalmsley
Mar 24 2016 18:55
@grokys iv just checked and textbox in the test app is also affected
to repro
1) Run test application
2) maximize application
3) goto input tab
4) try and select text, ok all working
now make window smaller
and drag to bottom right of screen
Steven Kirk
@grokys
Mar 24 2016 18:56
hmm, strange !
danwalmsley
@danwalmsley
Mar 24 2016 18:56
5) try and select text
Steven Kirk
@grokys
Mar 24 2016 18:56
not tried it yet, but how has no-one noticed that before?!?
danwalmsley
@danwalmsley
Mar 24 2016 18:56
you wont be able to, wrong coordinates coming out
iv been noticing weird things happening with my text selection for a while
but hadn't pinned it down
I remember seeing some DPI changes / Scaling changes not so long ago
perhaps it was introduced then?
ah I see why
Perspex isn't able to understand when my Windows is set to scale the display to 125%
image.png
that's what messes it up
if I then go back to 100% its ok
danwalmsley
@danwalmsley
Mar 24 2016 19:02
ah looks like this is #445
Darnell Williams
@Seeker1437
Mar 24 2016 19:02
@grokys can I request Row and Column Definitions support the Name Property?
Steven Kirk
@grokys
Mar 24 2016 19:03
ahhh ok, it's a scaling thing
yeah, that's still a bit buggy, mainly because i don't have a high DPI monitor
danwalmsley
@danwalmsley
Mar 24 2016 19:04
I had realised my laptop had gone to 125% scaling
where should I look in the code to try and fix it?
Steven Kirk
@grokys
Mar 24 2016 19:04
@Seeker1437 i don't think that would do much good as they're not in the logical tree so you won't be able to look them up even if you give them names
Darnell Williams
@Seeker1437
Mar 24 2016 19:04
FOr me I turned my scaling down to 100 because it's 125% facotry default :(
oh....
my mind is 100%wpf and can't change it to save my life lol
for them I could name them and change them from triggers
Steven Kirk
@grokys
Mar 24 2016 19:05
oh really? hmm, i didn't know that was possible in WPF
we should probably try to support it then
@danwalmsley this is where mouse events enter the system - https://github.com/Perspex/Perspex/blob/master/src/Perspex.Input/MouseDevice.cs#L106
Darnell Williams
@Seeker1437
Mar 24 2016 19:07
can I the TabStripProperty be used as a selector?
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0"/>
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                            <RowDefinition x:Name="RowDefinition1" Height="*"/>
                        </Grid.RowDefinitions>

//============================================================

                          <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="PART_HeaderItemsControl" Value="1"/>
                            <Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                            <Setter Property="Margin" TargetName="PART_HeaderItemsControl" Value="2,0,2,2"/>
                        </Trigger>
just an example
danwalmsley
@danwalmsley
Mar 24 2016 19:35
ah I wish Id never started with this popup thing!!!
ok right its all working great
as long as I put my context xaml for the popup inline
If it comes from a user control popup doesn't work
ok its official Popup is my least favorite control
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 19:47
@danwalmsley Try this if you are still interested in popups ;)
    public class PopupAction : PerspexObject, IAction
    {
        public static readonly PerspexProperty ChildProperty =
            PerspexProperty.Register<PopupAction, Control>(nameof(Child));

        [Content]
        public Control Child
        {
            get { return (Control)this.GetValue(ChildProperty); }
            set { this.SetValue(ChildProperty, value); }
        }

        private Popup _popup = null;

        public object Execute(object sender, object parameter)
        {
            if (_popup == null)
            {
                _popup = new Popup()
                {
                    PlacementMode = PlacementMode.Pointer,
                    PlacementTarget = sender as Control,
                    StaysOpen = false
                };

                var control = (sender as IControl);
                if (control != null)
                {
                    var data = control.GetObservable(Control.DataContextProperty);
                    if (data != null)
                    {
                        _popup.Bind(Control.DataContextProperty, data);
                    }
                }
            }
            _popup.Child = Child;
            _popup.Open();
            return null;
        }
    }
                <Grid RowDefinitions="Auto,*">
                    <TextBlock Text="Move Pointer" Name="position" Grid.Row="0" Margin="5" Background="{StyleResource GrayBrush}" Foreground="{StyleResource YellowBrush}" FontSize="14" TextAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                    <Border Name="border" Grid.Row="1" Margin="5,0,5,5" Background="{StyleResource GrayBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <i:Interaction.Behaviors>
                            <behaviors:ShowPointerPositionBehavior TargetTextBlock="{Binding #position}"/>
                            <ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #border}">
                                <actions:PopupAction>
                                    <Border Background="Yellow" BorderBrush="Red" BorderThickness="1" Padding="5">
                                        <TextBlock Text="{Binding Count}" Foreground="Red"/>
                                    </Border>
                                </actions:PopupAction>
                            </ia:EventTriggerBehavior>
                        </i:Interaction.Behaviors>
                        <TextBlock Text="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20"/>
                    </Border>
                </Grid
The Popup DataContext is bound to #border's DataContext
Darnell Williams
@Seeker1437
Mar 24 2016 19:53
:O
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 19:56
this works too:
                                <actions:PopupAction>
                                    <Border DataContext="{Binding Count}" Background="Yellow" BorderBrush="Red" BorderThickness="1" Padding="5">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Count: " Foreground="Red"/>
                                            <TextBlock Text="{Binding}" Foreground="Red"/>
                                        </StackPanel>
                                    </Border>
                                </actions:PopupAction>
danwalmsley
@danwalmsley
Mar 24 2016 20:00
@wieslawsoltes thanks pal
@wieslawsoltes what do you use for your screen recordings?
Wiesław Šoltés
@wieslawsoltes
Mar 24 2016 20:01
danwalmsley
@danwalmsley
Mar 24 2016 20:09
thanks
Steven Kirk
@grokys
Mar 24 2016 20:17
@danwalmsley please, if you have any suggestions to make Popup better let me know
at the moment it's kind of a half implemented version of WPFs
danwalmsley
@danwalmsley
Mar 24 2016 20:29
@grokys I think there are a few issues I need to fix in there
when I do
((ISetLogicalParent)popup).SetParent(AssociatedObject)
it doesn't trigger
/// <inheritdoc/>
        protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
        {
            base.OnAttachedToLogicalTree(e);
            _topLevel = e.Root as TopLevel;
        }
do _topLevel ends up being null
which I think is perhaps why weird things keep happening?
Steven Kirk
@grokys
Mar 24 2016 20:31
what type is AssociatedObject?
danwalmsley
@danwalmsley
Mar 24 2016 20:32
its a Control
TextEditor
but derives control
I guess without _topLevel set it might lead to 2 issues I'm seeing
1) not able to show UserControls
2) not able to display ListBox with
<ListBox.ItemsPanel>
                          <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0" />
                          </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
if I use a popup outside my behaviour, then It all works (the only difference I can see is _topLevel is set.
Steven Kirk
@grokys
Mar 24 2016 20:36
your best plan is probably to step into Perspex code to see why it's not being attached to the logical tree
danwalmsley
@danwalmsley
Mar 24 2016 20:41
my texteditor isn't attached to logical tree... that's wierd
ah I'm doing it when my content property is set so it might not have been then
ok fixed
private void AssociatedObject_AttachedToLogicalTree(object sender, Perspex.LogicalTree.LogicalTreeAttachmentEventArgs e)
        {
            ((ISetLogicalParent)popup).SetParent(AssociatedObject);
        }
had to set parent here
@grokys thanks for being patient with me
Steven Kirk
@grokys
Mar 24 2016 20:46
no problem - tonight of all nights i've got a lot of patience ;)
danwalmsley
@danwalmsley
Mar 24 2016 20:47
because of GitHub?
Steven Kirk
@grokys
Mar 24 2016 20:49
yeah :)
danwalmsley
@danwalmsley
Mar 24 2016 20:50
how soon do you start?
that's awesome
Steven Kirk
@grokys
Mar 24 2016 20:51
25th April
danwalmsley
@danwalmsley
Mar 24 2016 21:08
thanks guys
see video with my popup stuff working
Steven Kirk
@grokys
Mar 24 2016 21:14
excellent! glad you got it working finally
i hope to iron out these pain points eventally
better documentation would surely help too
Darnell Williams
@Seeker1437
Mar 24 2016 21:17
niiice sexy AvalonStudio :P
danwalmsley
@danwalmsley
Mar 24 2016 21:17
:D
I'm going to do a video for youtube soon once iv got a bit more polishing done... its almost usable now
danwalmsley
@danwalmsley
Mar 24 2016 21:25
@grokys just caught the exact line Perspex crashes with memory leak...
image.png
Steven Kirk
@grokys
Mar 24 2016 21:26
hmmm, wow
weird because that is a using statement
Steven Kirk
@grokys
Mar 24 2016 21:37
i think it's probably just a symptom of a leak somewhere else, but at least it tells me that the Direct2D part is leaking somewhere
danwalmsley
@danwalmsley
Mar 24 2016 21:38
is anyone actively working on skia?
Steven Kirk
@grokys
Mar 24 2016 21:39
don't think so, kekekeks seems to have taken a break
and his last pull to skia# seems to have gone ignored
danwalmsley
@danwalmsley
Mar 24 2016 21:43
is skia still along way off being usable?
Darnell Williams
@Seeker1437
Mar 24 2016 22:01
si XD
Yay bugs
nvm
Steven Kirk
@grokys
Mar 24 2016 22:09
i think it's a fair way along
but needs a bit of love - shame the skia# haven't even replied to the PR
if we could use skia# it would be a lot easier
danwalmsley
@danwalmsley
Mar 24 2016 22:10
@grokys Imagine I have 2 controls in a stack panel
and I make 1 invisible
how do I get the other one to fill the space
in WPF this was covered by visibility = hidden / collapsed
but in Perspex doesn't seem to work?
Steven Kirk
@grokys
Mar 24 2016 22:14
yeah, we don't have the Visibility enum because it was a pain for 99% of cases
danwalmsley
@danwalmsley
Mar 24 2016 22:14
yeh I completely agree
Steven Kirk
@grokys
Mar 24 2016 22:14
instead do it like in html: set Opacity=0 and IsHitTestVisible=false
danwalmsley
@danwalmsley
Mar 24 2016 22:15
ok
Perhaps we can have an IsCollapsed?
can bindings have expression
i.e. Opacity = {Binding Visible ? 0 : 100}?
that doesn't seem to work... just leaves empty space where the control was
maybe IsCollapsed is best way forward?
Darnell Williams
@Seeker1437
Mar 24 2016 22:20
Lo that would be cool we could call it FuncBinding, ReturnType=[system:Boolean}, Epression = [IsVisible ? 0 : 100]
xD
Jeremy Koritzinsky
@jkoritzinsky
Mar 24 2016 22:21
I think we should have IsCollapsed. That way the name is self-explanetory.
*explanatory
Darnell Williams
@Seeker1437
Mar 24 2016 22:21
lol true :P
But logical is too direct D:
(joking)
danwalmsley
@danwalmsley
Mar 24 2016 22:24
@Seeker1437 its coming together now... still polishing is really the difficult bit
Darnell Williams
@Seeker1437
Mar 24 2016 22:26
Lol niiiice!
Steven Kirk
@grokys
Mar 24 2016 22:26
@jkoritzinsky yeah maybe - but in my experience it's not such a common thing
we'll see how many people ask for it
though it could easily be done as an attached property
and html people don't have a problem with Opacity=0 and IsHitTestVisible=false
i've been doing WPF and HTML for like 10 years and i can count on one hand how many times i've needed it
danwalmsley
@danwalmsley
Mar 24 2016 22:28
@grokys that didn't work for me
Steven Kirk
@grokys
Mar 24 2016 22:28
what happened?
danwalmsley
@danwalmsley
Mar 24 2016 22:28
setting that on items inside a stack panel
the stack panel didn't collapse
it just left an empty space where the control was
Steven Kirk
@grokys
Mar 24 2016 22:29
yeah, that's what Visibility=Collapsed did in WPF
Darnell Williams
@Seeker1437
Mar 24 2016 22:29
Maybe the IsHitTestVisible is not affectingMeasure?
oh nvm x3
Steven Kirk
@grokys
Mar 24 2016 22:29
oh sorry, Visibility=Hidden
Darnell Williams
@Seeker1437
Mar 24 2016 22:30
yeah we need ccolllapsed
Steven Kirk
@grokys
Mar 24 2016 22:30
Visibility=Collapsed is IsVisible=false
Darnell Williams
@Seeker1437
Mar 24 2016 22:30
where the heght is also set to 0
Steven Kirk
@grokys
Mar 24 2016 22:30
IsVisible=false completely hides and collapses the control as you'd expect
Darnell Williams
@Seeker1437
Mar 24 2016 22:31
you made it something directy accessible so people dont have to have the BooleanToVisibility Ugliness :DD
Steven Kirk
@grokys
Mar 24 2016 22:31
yeah
i hate that
Imagine I have 2 controls in a stack panel and I make 1 invisible. how do I get the other one to fill the space
i guess i don't understand the question
Darnell Williams
@Seeker1437
Mar 24 2016 22:32
Oh dan, you want it to streath when the other one is collapsed?
stretch
that where the ContentAllighment Properties might help maybe?
assuming your stackpanell has a fixed size
danwalmsley
@danwalmsley
Mar 24 2016 22:35
ah ok will try tyhat
Steven Kirk
@grokys
Mar 24 2016 22:35
what is the WPF you're trying to emulate?
danwalmsley
@danwalmsley
Mar 24 2016 22:35
If I put 3 controls in a stack panel
then do Visibility Collapsed on the middle one
then the other 2 will consume the space where the original one was
Steven Kirk
@grokys
Mar 24 2016 22:36
ok, just set it's IsVisible=false
Darnell Williams
@Seeker1437
Mar 24 2016 22:36
VerticalContentAlighnment possibl
q
danwalmsley
@danwalmsley
Mar 24 2016 22:36
just setting isvisible = false didn't do it
il try content alignment
Darnell Williams
@Seeker1437
Mar 24 2016 22:37
Making it Stretch should do
danwalmsley
@danwalmsley
Mar 24 2016 22:38
<Grid Grid.Row="2" Grid.Column="2" Margin="1 1 2 2">
  <StackPanel Orientation="Horizontal" Gap="4">        
    <Controls:CallStack DataContext="{Binding DebugManager.CallStack}" Width="400" />
    <Controls:Disassembly DataContext="{Binding DebugManager.Disassembly}" Width="400" />
    <Controls:Locals DataContext="{Binding DebugManager.Locals}" Width="400" />
  </StackPanel>          
</Grid>
content alignment doesn't apply to grid or stackpanel
as far as I can tell
Idea is those controls I need the stackpanel to get smaller if they disapear
Darnell Williams
@Seeker1437
Mar 24 2016 22:39
Oh the grkys solution should work
weirdif it doesnt
Steven Kirk
@grokys
Mar 24 2016 22:41
i don't understand how setting IsVisible=false doesn't work
if i have:
This message was deleted
<StackPanel>
        <TextBlock>Item1</TextBlock>
        <TextBlock>Item2</TextBlock>
        <TextBlock>Item3</TextBlock>
</StackPanel>
i get this
blob
changing to:
      <StackPanel>
        <TextBlock>Item1</TextBlock>
        <TextBlock IsVisible="False">Item2</TextBlock>
        <TextBlock>Item3</TextBlock>
      </StackPanel>
i get this:
blob
isn't that what you want??!
Darnell Williams
@Seeker1437
Mar 24 2016 22:48
No i think he wants item1 and item 3 to stretch evenly and take te spave of item 2
stackpanel hight would not change
a
Steven Kirk
@grokys
Mar 24 2016 22:50
ah ok, that's not how StackPanel works
not just in perspex, in WPF too
danwalmsley
@danwalmsley
Mar 24 2016 22:53
@grokys does your examole work with orientation horizontal?
Steven Kirk
@grokys
Mar 24 2016 22:53
yeah, sure
danwalmsley
@danwalmsley
Mar 24 2016 22:53
Because mine was exactly like yours
Steven Kirk
@grokys
Mar 24 2016 22:54
setting IsVisible=false hides the control, as you'd expect
try it!
danwalmsley
@danwalmsley
Mar 24 2016 22:54
But it didnt move to left when first was hidden
Steven Kirk
@grokys
Mar 24 2016 22:54
in a new xaml file i mean
danwalmsley
@danwalmsley
Mar 24 2016 22:54
Ok il try again
Steven Kirk
@grokys
Mar 24 2016 22:54
copy paste the example
danwalmsley
@danwalmsley
Mar 24 2016 23:11
@grokys ok your example does work
its when I bind isvisible it stops working
Steven Kirk
@grokys
Mar 24 2016 23:11
hmm
what does the devtools say is the value of IsVisible?
danwalmsley
@danwalmsley
Mar 24 2016 23:12
ah this is an issue iv come across every now and again
if a property name is too long binding doesn't work
my property name is
<Grid Grid.Row="2" Grid.Column="2" Margin="1 1 2 2" >
      <StackPanel Orientation="Horizontal" Gap="4">        
        <Controls:CallStack DataContext="{Binding DebugManager.CallStack}" Width="400" IsVisible="{Binding DebugControlsVisible}" />
        <Controls:Disassembly DataContext="{Binding DebugManager.Disassembly}" Width="400" />
        <Controls:Locals DataContext="{Binding DebugManager.Locals}" Width="400" />
      </StackPanel>          
    </Grid>
{Binding DebugControlsVisible}
I'm going to shorten the property name now
no its not that... but that is an issue iv come across
ok its my datacontext...
Steven Kirk
@grokys
Mar 24 2016 23:16
really? it doesn't handle long property names?!? wow
i can't imagine why that is
please submit a bug if you can reproduce it
danwalmsley
@danwalmsley
Mar 24 2016 23:17
I'm just testing now, iv definitely come across that
<Grid Grid.Row="2" Grid.Column="2" Margin="1 1 2 2" Name="debugContainer" >
      <StackPanel Orientation="Horizontal" Gap="4">        
        <Controls:CallStack DataContext="{Binding DebugManager.CallStack}" Width="400" IsVisible="{Binding #debugContainer.DataContext.DebugVisible}" />
        <Controls:Disassembly DataContext="{Binding DebugManager.Disassembly}" Width="400" />
        <Controls:Locals DataContext="{Binding DebugManager.Locals}" Width="400" />
      </StackPanel>          
    </Grid>
does that Binding expression look correct?
Steven Kirk
@grokys
Mar 24 2016 23:25
i think so yeah
Steven Kirk
@grokys
Mar 24 2016 23:37
i definitely think my next job is to improve diagnostics to make this sort of thing clearer
danwalmsley
@danwalmsley
Mar 24 2016 23:38
="{Binding #debugContainer.DataContext.DebugVisible}"
didn't work
maybe because the controls datacontext is overridden it stops that kind of binding working too
Steven Kirk
@grokys
Mar 24 2016 23:45
hmm, strange
just did a test of a similar construct in a test app and seemed to work
danwalmsley
@danwalmsley
Mar 24 2016 23:53
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
        <Grid>
          <Controls:Registers DataContext="{Binding DebugManager.Registers}" HorizontalAlignment="Left" />
        </Grid>
        <Controls:Editor DataContext="{Binding Editor}" HorizontalAlignment="Stretch" Width="100" />  
      </StackPanel>
the editor doesn't have a width
(ignore the width 100, iv taken it out)
I cant get it to take up maximum possible size
Steven Kirk
@grokys
Mar 24 2016 23:56
i think it would be really useful if you tried to reproduce these issues in a simple app
because it's really hard to know if its a Perspex problem or something in your code otherwise
danwalmsley
@danwalmsley
Mar 24 2016 23:58
ok i'll do a repro
Steven Kirk
@grokys
Mar 24 2016 23:58
and it's been more than a couple of times that i've gone into avalonstudio to investigate and found it's a problem there ;) just sayin ;)
just that i've drank a few :beers: right now so not really in a position to investigate myself!