These are chat archives for AvaloniaUI/Avalonia

24th
Dec 2015
danwalmsley
@danwalmsley
Dec 24 2015 12:25 UTC
anyone know how the following scenario can be acheived?
I have an object of type ISourceFile....
it can be passed to the language service for analysis... ISourceFile knows nothing of LanguageServices...
(ILanguageService)
when one of the LanguageServices (for c++) analyses the code, it produces a syntax tree... I need to attach the syntax tree somehow to the ISourceFile
so that the next time code analysis is run the ILanguageService and access the SyntaxTree object...
is the a way to do this with a normal object? without changing the code of the ISourceFile?
Darnell Williams
@Seeker1437
Dec 24 2015 12:31 UTC
I will l'm gonna peek at the source to see if i can try and help. Don't count on me though XD.
Steven Kirk
@grokys
Dec 24 2015 12:59 UTC
you mean attach arbitrary objects to another object?
the usual way to do that is just by associating them using a Dictionary or ConditionalWeakTable if their lifetimes are independent
Seeker1437 @ImaBrokeDude 's mind was blown
danwalmsley
@danwalmsley
Dec 24 2015 13:53 UTC
if their lifetimes are dependent?
is there another way?
Steven Kirk
@grokys
Dec 24 2015 13:58 UTC
well if ISourceFile knows nothing of LanguageServices, then the association can't be in ISourceFile
danwalmsley
@danwalmsley
Dec 24 2015 13:59 UTC
I thought maybe some kind of attachedProperty?
Steven Kirk
@grokys
Dec 24 2015 13:59 UTC
so the association has to be at the language services level
Darnell Williams
@Seeker1437
Dec 24 2015 14:00 UTC
In all fairness, I thin ISourceFile should be used to determine the LanguageService based off it's metadata.
Steven Kirk
@grokys
Dec 24 2015 14:00 UTC
the easiest way to "attach" a property to something is by: Dictionary<ISourceFile, LanguageService>
danwalmsley
@danwalmsley
Dec 24 2015 14:00 UTC
ok thanks
Darnell Williams
@Seeker1437
Dec 24 2015 14:00 UTC
ISourceFile would still know nothing of it's LanguageService, but you could always get that correct Language service because of the metadata contained in ISourceFile
idk if that is good though XD
danwalmsley
@danwalmsley
Dec 24 2015 14:01 UTC
How can you tell / be notified when ISourceFile is destroyed? would I need an event?
Darnell Williams
@Seeker1437
Dec 24 2015 14:02 UTC
for me or grokys?
danwalmsley
@danwalmsley
Dec 24 2015 14:03 UTC
both
Darnell Williams
@Seeker1437
Dec 24 2015 14:05 UTC
I would do an event, with an enumeration of it's cause
that way you could still use MEF to handle it
This message was deleted
oh wow
Steven Kirk
@grokys
Dec 24 2015 14:12 UTC
well that's what i was saying about lifetimes
if you use a ConditionalWeakTable then the two will be weakly related so LanguageService won't keep ISourceFile alive
Darnell Williams
@Seeker1437
Dec 24 2015 14:15 UTC
I have never heard of a ConditionalWeakTable but it seems pretty epic
Johan Larsson
@JohanLarsson
Dec 24 2015 14:26 UTC
Yes it is nice for caching.
Wiesław Šoltés
@wieslawsoltes
Dec 24 2015 15:43 UTC

@grokys With this XAML:

                <Grid RowDefinitions="Auto,100">
                    <TextBox Name="textBox" Text="Hello" Grid.Row="0"/>
                    <Button Name="button" Content="Change Property" Grid.Row="1">
                        <i:Interaction.Behaviors>
                            <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding ElementName=button}">
                                <ia:ChangePropertyAction TargetObject="{Binding ElementName=textBox}" PropertyName="Text" Value="World"/>
                            </ia:EventTriggerBehavior>
                        </i:Interaction.Behaviors>
                    </Button>
                </Grid>

I get the exception:

Error loading XAML: System.InvalidCastException: Nie można rzutować obiektu typu 'Perspex.Xaml.Interactions.Core.EventTriggerBehavior' na typ 'Perspex.Controls.IControl'.
   w Perspex.Markup.Xaml.Data.Binding.CreateSubject(IObservablePropertyBag target, Type targetType, Boolean targetIsDataContext) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\Data\Binding.cs:wiersz 98
   w Perspex.Markup.Xaml.Data.Binding.Bind(IObservablePropertyBag instance, PerspexProperty property) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\Data\Binding.cs:wiersz 63
   w Perspex.Markup.Xaml.Context.PerspexXamlMemberValuePlugin.ApplyBinding(Object instance, IXamlBinding binding) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\Context\PerspexXamlMemberValuePlugin.cs:wiersz 129
   w Perspex.Markup.Xaml.Context.PerspexXamlMemberValuePlugin.HandleBinding(Object instance, IXamlBinding binding) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\Context\PerspexXamlMemberValuePlugin.cs:wiersz 87
   w Perspex.Markup.Xaml.Context.PerspexXamlMemberValuePlugin.SetValue(Object instance, Object value) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\Context\PerspexXamlMemberValuePlugin.cs:wiersz 44
   w OmniXaml.Typing.MutableXamlMember.SetValue(Object instance, Object value) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\Typing\MutableXamlMember.cs:wiersz 56
   w OmniXaml.ObjectAssembler.StateCommuter.AssignChildToParentProperty() w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\ObjectAssembler\StateCommuter.cs:wiersz 69
   w OmniXaml.ObjectAssembler.StateCommuter.AssociateCurrentInstanceToParent() w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\ObjectAssembler\StateCommuter.cs:wiersz 171
   w OmniXaml.ObjectAssembler.Commands.EndObjectCommand.Execute() w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\ObjectAssembler\Commands\EndObjectCommand.cs:wiersz 29
   w OmniXaml.ObjectAssembler.ObjectAssembler.Process(XamlInstruction instruction) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\ObjectAssembler\ObjectAssembler.cs:wiersz 76
   w OmniXaml.TemplateHostingObjectAssembler.Process(XamlInstruction instruction) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\TemplateHostingObjectAssembler.cs:wiersz 77
   w Perspex.Markup.Xaml.Context.PerspexObjectAssembler.Process(XamlInstruction node) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\Context\PerspexObjectAssembler.cs:wiersz 40
   w OmniXaml.XamlXmlParser.Parse(IEnumerable`1 xamlNodes) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\XamlXmlParser.cs:wiersz 33
   w OmniXaml.XamlXmlParser.Parse(IXmlReader stream) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\XamlXmlParser.cs:wiersz 28
   w OmniXaml.XamlXmlLoader.Load(Stream stream, IXamlParser parser) w C:\DOWNLOADS\GitHub-Perspex\Perspex\src\Markup\Perspex.Markup.Xaml\OmniXAML\Source\OmniXaml\XamlXmlLoader.cs:wiersz 32
danwalmsley
@danwalmsley
Dec 24 2015 15:45 UTC
@grokys thanks ConditionalWeakTable is exactly what I'm looking for :D
Wiesław Šoltés
@wieslawsoltes
Dec 24 2015 16:06 UTC
@grokys The EventTriggerBehavior class is based on PerspexObject when I change it to Control than exception is not thrown
in WPF this works on level of PerspexObject
Steven Kirk
@grokys
Dec 24 2015 16:09 UTC
i'm guessing it's because Binding currently expects to find a DataContext on the control it's being bound to
Wiesław Šoltés
@wieslawsoltes
Dec 24 2015 16:10 UTC
I dont think its related to DataContext
Steven Kirk
@grokys
Dec 24 2015 16:11 UTC
what do you think it's related to?
Wiesław Šoltés
@wieslawsoltes
Dec 24 2015 16:11 UTC
This message was deleted
This message was deleted
the class ia:EventTriggerBehavior is based on PerspexObject but Perspex binding is expecting IControl
and the ia:EventTriggerBehavior class is not UI related but is using Binding system
Steven Kirk
@grokys
Dec 24 2015 16:15 UTC
ah right yeah, that sounds correct
ControlLocator requires a control to know where to look for the named control
Wiesław Šoltés
@wieslawsoltes
Dec 24 2015 16:18 UTC
I'm binding to named control, but the SourceObject property belongs to class based on PerspexObject and why is necessary for it to also be IControl ?
the Binding to ElementName is tied to IControl and not to PerspexObject
Steven Kirk
@grokys
Dec 24 2015 16:22 UTC
because i'd not forseen what you're doing
tbh, i'm starting to think some of the basic decisions i made early on were wrong
i'm starting to get worried none of this will ever work correctly
Wiesław Šoltés
@wieslawsoltes
Dec 24 2015 16:40 UTC
Well I think this is just are edge cases, I am pretty happy how Perspex works
This issue comes from Xaml Behaviors, which use attaché properties to extreme ;)
Steven Kirk
@grokys
Dec 24 2015 17:49 UTC
my main worry is that styles are going to cause too much memory usage...
also it's starting to get to the point where small changes break a lot
so i'm wondering if we can componentize stuff a bit better
danwalmsley
@danwalmsley
Dec 24 2015 18:01 UTC
@grokys iv git TextView = ContentControl... and TextEditor = TemplatedControl
TextEditor AddsOwner on TextView.ContentProperty..
and then I add stuff on the TextEditor content, TextView.ContentProperty is unset...
how do I tell Perspex that TextEditors Content Property = Content?
Steven Kirk
@grokys
Dec 24 2015 18:04 UTC
haha, you keep getting confused by this
danwalmsley
@danwalmsley
Dec 24 2015 18:04 UTC
yup
:D
Steven Kirk
@grokys
Dec 24 2015 18:04 UTC
AddOwner doesn't mean that the two values are bound in any way, it just registers a property on a type
Johan Larsson
@JohanLarsson
Dec 24 2015 18:04 UTC
nice to see that you guys don't stop just cos it is Christmas :)
Steven Kirk
@grokys
Dec 24 2015 18:04 UTC
you need to actually bind the two values together if you want them to be bound
danwalmsley
@danwalmsley
Dec 24 2015 18:05 UTC
ah yes... so in the template I need to bind them
ah thanks
@JohanLarsson haha... except today its accompanied by...
Steven Kirk
@grokys
Dec 24 2015 18:05 UTC
@JohanLarsson ha yeah. though after christmas i'm on holiday for 10 days, so that'll be my time to relax ;)
Steven Kirk
@grokys
Dec 24 2015 18:06 UTC
man moretti is getting popular over in the UK!
i've seen it everywhere
danwalmsley
@danwalmsley
Dec 24 2015 18:06 UTC
probably @grokys gets that where you are?
Steven Kirk
@grokys
Dec 24 2015 18:06 UTC
in italy that's like fosters
danwalmsley
@danwalmsley
Dec 24 2015 18:06 UTC
yeh... its really good
Johan Larsson
@JohanLarsson
Dec 24 2015 18:06 UTC
I've been coding all day also, same as all days
danwalmsley
@danwalmsley
Dec 24 2015 18:06 UTC
haha im sure
probably helps !
Steven Kirk
@grokys
Dec 24 2015 18:07 UTC
i drink it all the time, but only cos it's cheap ;)
danwalmsley
@danwalmsley
Dec 24 2015 18:07 UTC
yeh here its not
Steven Kirk
@grokys
Dec 24 2015 18:07 UTC
it's the cheapest you can get over there
danwalmsley
@danwalmsley
Dec 24 2015 18:07 UTC
its like a "premium" since its you know "Italian" it must be good
you in Uk for Christmas then?
Steven Kirk
@grokys
Dec 24 2015 18:07 UTC
but the italians love tennants super, so no accounting for taste!
yeah, back for a bit
danwalmsley
@danwalmsley
Dec 24 2015 18:08 UTC
haha now that is ironic
Steven Kirk
@grokys
Dec 24 2015 18:08 UTC
they drink tennants super from little bottles, with a wine-glass type thing
it's weird
just shows the power of marketing!
if they can be convinced that shit tastes good
danwalmsley
@danwalmsley
Dec 24 2015 18:09 UTC
yeh... do they get adverts on the TV showing the typical clientel for that then... all wearing suits and having a good time
Steven Kirk
@grokys
Dec 24 2015 18:09 UTC
not got a tv - but probably
danwalmsley
@danwalmsley
Dec 24 2015 18:10 UTC
well it worked with the moretti for me too
do I need a template binding then?
like this..
<tv:TextView Name="textView" HorizontalAlignment="Stretch" Margin="0, 0" Grid.Column="1"
                            CaretIndex="{TemplateBinding CaretIndex}"
                            SelectionStart="{TemplateBinding SelectionStart}"
                            SelectionEnd="{TemplateBinding SelectionEnd}"
                            Foreground="{TemplateBinding Foreground}"
                            TextDocument="{TemplateBinding TextDocument}" 
                            Content="{TemplateBinding Content} "/>
thats on the TextEditor... need TextEditor.ContentProperty to bind to TextView.Content
Steven Kirk
@grokys
Dec 24 2015 18:13 UTC
yeah i think so... to be sure, take a look at how it's done in TextBox https://github.com/Perspex/Perspex/blob/master/src/Perspex.Themes.Default/TextBox.paml#L37
danwalmsley
@danwalmsley
Dec 24 2015 18:16 UTC
yes that works :D
Johan Larsson
@JohanLarsson
Dec 24 2015 18:17 UTC
so nice to test views when writing custom stuff
danwalmsley
@danwalmsley
Dec 24 2015 18:20 UTC
does anyone know if there is something like appveyor, but for c / c++ projects?
danwalmsley
@danwalmsley
Dec 24 2015 18:28 UTC
found a minor bug...
<TabItem>
with no content... causes null exception
I know its not valid... but it crashes at runtime
Steven Kirk
@grokys
Dec 24 2015 20:03 UTC
ah ok, could you file an issue?