These are chat archives for AvaloniaUI/Avalonia

12th
Jan 2016
Ethan Smith
@ethanhs
Jan 12 2016 01:10
I'm thinking of porting MahApps to Perspex. If I run into an issue can I bring it here?
Darnell Williams
@Seeker1437
Jan 12 2016 01:48
dooet :D
Ethan Smith
@ethanhs
Jan 12 2016 01:58
I'm thinking the least portable part is the win32 calls. I can set it up so that it will use native gtk calls on nix and native win32 calls on windows. I think for sanities sake, I'll keep the win32 naming and alias the gtk calls. On mobile the windowing won't matter (though I'll be starting with only windows and nix)
Nikita Tsukanov
@kekekeks
Jan 12 2016 07:14

. I can set it up so that it will use native gtk

Don't do that

GTK# bindings will be replaced by something else entirely
If you want to create libs for perspex, please, stick to PCL
It will ensure that they will run on coreclr or whatever platform we'll be porting perspex to in the future
Steven Kirk
@grokys
Jan 12 2016 11:17
it might be useful if someone could compile a list of the windows-specific APIs that mahapps uses and we can talk about how to expose them in a platform-independent manner
Darnell Williams
@Seeker1437
Jan 12 2016 11:20
Ah I think I can do that
Though starting I can already name Microsoft.Standard namespace xD
but @IronManMark20 might be better suited
Hes gonna dig in it xD
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:25
They are using custom wndproc and some GDI-based drawing calls
They also use layered windows for some reason
danwalmsley
@danwalmsley
Jan 12 2016 11:26
do you need to do a full port? I would have thought you could just port the controls / control templates?
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:26
They also use some DWM magic to draw stuff on top of native window frame
Darnell Williams
@Seeker1437
Jan 12 2016 11:26
yeah for the glowbrush and flyouts
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:27
Basically they only use winapi for toplevel window frame stuff
Darnell Williams
@Seeker1437
Jan 12 2016 11:27
Some of the things the controls do Perspex might already have natively but not all
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:27
i. e. MetroWindow
Which can be drawn without DWM effects
Darnell Williams
@Seeker1437
Jan 12 2016 11:28
sorta the error validation popup
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:28
Like they do it on WinXP
Darnell Williams
@Seeker1437
Jan 12 2016 11:28
uses the winapi to move with the window
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:28
We have BeginMoveDrag/BeginResizeDrag
Darnell Williams
@Seeker1437
Jan 12 2016 11:29
Some of the things the controls do Perspex might already have natively
Steven Kirk
@grokys
Jan 12 2016 11:40
ok, well if the controls can ported without platform specific APIs then that would be the place to start
danwalmsley
@danwalmsley
Jan 12 2016 11:41
like when I did the watermark for textbox a while back I essentially looked at what mahapps did there
it wasnt a port
but it was more - or less a copy of the design
maybe that would be an approach, go control by control, and implement the same design
but not actually porting their code?
Steven Kirk
@grokys
Jan 12 2016 11:43
yeah, i think that's how it'd have to be done
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:43
We definetely need to port their control theme
Steven Kirk
@grokys
Jan 12 2016 11:43
there will be things missing/broken i expect
Nikita Tsukanov
@kekekeks
Jan 12 2016 11:43
It looks much better than one that we currently have
danwalmsley
@danwalmsley
Jan 12 2016 11:44
for sure
Steven Kirk
@grokys
Jan 12 2016 11:44
and our animation system isn't as powerful as WPF's yet (at all!)
danwalmsley
@danwalmsley
Jan 12 2016 11:44
once someone starts doing this it will find all the holes that need to be filled
so it will be quite beneficial
Steven Kirk
@grokys
Jan 12 2016 11:45
yep, as long as they're prepared for lots of roadblocks ;)
but as kekekeks said, their controls look a lot better than ours
our controls are kinda a half-baked version of theirs, mainly because historically that's the best we could get
due to missing/broken stuff
danwalmsley
@danwalmsley
Jan 12 2016 11:47
id say, go through all our existing controls 1 by one and update them
as best as the current perspex allows
using mahapp as a design guide
that would give us a huge visual update
even if it didnt get you to 100% identical with mahapps
Steven Kirk
@grokys
Jan 12 2016 11:49
yep, that sounds like a good plan
danwalmsley
@danwalmsley
Jan 12 2016 11:52
@grokys sorry to pester, any ideas about the ContentPanel problem I was having?
Steven Kirk
@grokys
Jan 12 2016 11:57
not yet - need to catch up with work first
you could try debugging it yourself if you like
danwalmsley
@danwalmsley
Jan 12 2016 11:58
ok will have a look
cheers
danwalmsley
@danwalmsley
Jan 12 2016 15:06
@grokys found the problem
not sure why
but I did
Ethan Smith
@ethanhs
Jan 12 2016 15:06
So, um, got the memo on making a pcl. The first issue I'll run into is there doesn't seem to be Resources? Or resource dictionaries. ..
danwalmsley
@danwalmsley
Jan 12 2016 15:07
{Binding DataContext}
didnt work
{Binding }
did
  <ContentControl Content="{Binding }">
          <ContentControl.DataTemplates>
            <DataTemplate DataType="ViewModels:PackageManagerDialogViewModel">
              <Controls:PackageManagerDialog />
            </DataTemplate>
            <DataTemplate DataType="ViewModels:ProjectConfigurationDialogViewModel">
              <Controls:ProjectConfigurationDialog />
            </DataTemplate>
          </ContentControl.DataTemplates>
        </ContentControl>
Ethan Smith
@ethanhs
Jan 12 2016 15:08
Maybe I should learn a bit more on perspex styling before I get started on this, it seems significantly different.
danwalmsley
@danwalmsley
Jan 12 2016 15:08
is Binding DataContext different?
Steven Kirk
@grokys
Jan 12 2016 15:08
right, because {Binding DataContext} is saying bind to a property DataContext on the data context
danwalmsley
@danwalmsley
Jan 12 2016 15:08
ah of course
i get it
cheers
Steven Kirk
@grokys
Jan 12 2016 15:09
did you step though the perspex source to work that out?
danwalmsley
@danwalmsley
Jan 12 2016 15:09
I was going to... I set up the same scenario in the perspex test app
and it worked first time
so I was like must have done something stupid
Steven Kirk
@grokys
Jan 12 2016 15:10
@IronManMark20 yes, they are the thing that differs most from WPF
danwalmsley
@danwalmsley
Jan 12 2016 15:10
then saw id made that mistake
i really need an easy way of using perspex as a submodule rather than nuget will make debugging these things easier... im guessing nuget has nt been fixed to allow that yet?
if it was nuget that made it difficult i cant remember
Steven Kirk
@grokys
Jan 12 2016 15:11
yeah that was the problem
not been fixed as far as i know, though apparently moving to .net core's project.json will fix it
the way i do it, is just build perspex and copy the Pespex.* dlls into your project's Perspex nuget directory in the packages dir
if you do that, the debugger will pick up your debugging info and you can step etc
Ethan Smith
@ethanhs
Jan 12 2016 15:16
Thanks @grokys I was able to figure some of that out, but that is very helpful
Steven Kirk
@grokys
Jan 12 2016 15:18
if there's anything else you need to know, let me know and i can add it (or submit a PR for the docs!)
Nikita Tsukanov
@kekekeks
Jan 12 2016 15:21

not been fixed as far as i know, though apparently moving to .net core's project.json will fix it

I'm not sure that you can build PCLs with that

Or reference that stuff from regular apps
That's the issue with project.json, once you start using it somewhere you need to use it everywhere
And mobile apps currently can't be built using project.json
Steven Kirk
@grokys
Jan 12 2016 15:23
right, yeah, i think we need to wait for things to stabilize before we move to the Brave New World of project.json
Nikita Tsukanov
@kekekeks
Jan 12 2016 15:37
It also have some issues with configuring build actions
You can write wildcard for all .paml files to be compiled as EmbeddedResource through
Which is actually better than marking each one as a resource
Steven Kirk
@grokys
Jan 12 2016 15:53
that sounds great
danwalmsley
@danwalmsley
Jan 12 2016 16:42
@grokys do you think this should work?
<TabItem Header="Compile" Content="{Binding Model.ToolChain.CompileContent}">

      </TabItem>
binding content property
I keep getting exceptions as soon as I click on the tab
   at Perspex.Controls.Primitives.SelectingItemsControl.MarkContainerSelected(IControl container, Boolean selected)
   at Perspex.Controls.Primitives.SelectingItemsControl.SelectedItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Perspex.Collections.PerspexList`1.NotifyReset(IList t)
   at Perspex.Collections.PerspexList`1.Clear()
   at Perspex.Collections.PerspexList`1.System.Collections.IList.Clear()
   at Perspex.Controls.Primitives.SelectingItemsControl.set_SelectedItem(Object value)
   at Perspex.Controls.Primitives.SelectingItemsControl.set_SelectedIndex(Int32 value)
   at Perspex.Controls.Primitives.SelectingItemsControl.<>c.<.cctor>b__11_2(SelectingItemsControl o, Int32 v)
   at Perspex.PerspexProperty.<>c__DisplayClass70_0`2.<Cast>b__0(PerspexObject o, TValue v)
   at Perspex.PerspexProperty`1.<>c__DisplayClass16_0`1.<CastParams>b__0(PerspexObject o, Object v)
   at Perspex.PerspexObject.SetValue(PerspexProperty property, Object value, BindingPriority priority)
   at Perspex.PerspexObject.<>c__DisplayClass34_0.<Bind>b__1(Object x)
   at System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
   at System.Reactive.Linq.ObservableImpl.Select`2._.OnNext(TSource value)
   at System.Reactive.SafeObserver`1.OnNext(TSource value)
   at System.Reactive.Linq.ObservableImpl.Select`2._.OnNext(TSource value)
   at System.Reactive.AutoDetachObserver`1.OnNextCore(T value)
   at System.Reactive.ObserverBase`1.OnNext(T value)
   at Perspex.Markup.Data.ExpressionNode.set_CurrentValue(Object value)
   at Perspex.Markup.Data.PropertyAccessorNode.SetCurrentValue(Object value)
   at System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
   at System.Reactive.Linq.ObservableImpl.Skip`1._.OnNext(TSource value)
   at System.Reactive.AutoDetachObserver`1.OnNextCore(T value)
   at System.Reactive.ObserverBase`1.OnNext(T value)
   at Perspex.PerspexObject.<>c__DisplayClass26_1.<GetObservable>b__1(Object s, PerspexPropertyChangedEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at Perspex.PerspexObject.RaisePropertyChanged(PerspexProperty property, Object oldValue, Object newValue, BindingPriority priority)
   at Perspex.Controls.Primitives.SelectingItemsControl.set_SelectedIndex(Int32 value)
   at Perspex.Controls.Primitives.SelectingItemsControl.<>c.<.cctor>b__11_2(SelectingItemsControl o, Int32 v)
   at Perspex.PerspexProperty.<>c__DisplayClass70_0`2.<Cast>b__0(PerspexObject o, TValue v)
   at Perspex.PerspexProperty`1.<>c__DisplayClass16_0`1.<CastParams>b__0(PerspexObject o, Object v)
   at Perspex.PerspexObject.SetValue(PerspexProperty property, Object value, BindingPriority priority)
   at Perspex.Markup.Data.Plugins.PerspexPropertyAccessorPlugin.Accessor.SetValue(Object value)
   at Perspex.Markup.Data.PropertyAccessorNode.SetValue(Object value)
   at Perspex.Markup.Data.ExpressionObserver.SetValue(Object value)
   at Perspex.Markup.Data.ExpressionSubject.OnNext(Object value)
   at System.Reactive.AutoDetachObserver`1.OnNextCore(T value)
   at System.Reactive.ObserverBase`1.OnNext(T value)
   at Perspex.PerspexObject.<>c__DisplayClass26_1.<GetObservable>b__1(Object s, PerspexPropertyChangedEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at Perspex.PerspexObject.RaisePropertyChanged(PerspexProperty property, Object oldValue, Object newValue, BindingPriority priority)
   at Perspex.Controls.Primitives.SelectingItemsControl.set_SelectedIndex(Int32 value)
   at Perspex.Controls.Primitives.SelectingItemsControl.UpdateSelection(Int32 index, Boolean select, Boolean rangeModifier, Boolean toggleModifier)
   at Perspex.Controls.Primitives.SelectingItemsControl.UpdateSelection(IControl container, Boolean select, Boolean rangeModifier, Boolean toggleModifier)
   at Perspex.Controls.Primitives.SelectingItemsControl.UpdateSelectionFromEventSource(IInteractive eventSource, Boolean select, Boolean rangeModifier, Boolean toggleModifier)
   at Perspex.Controls.Primitives.TabStrip.OnPointerPressed(PointerPressEventArgs e)
   at Perspex.Interactivity
basically im trying to inject a view from a pluging, which is why I need to bind the content...
Steven Kirk
@grokys
Jan 12 2016 16:44
yeah, that should work i think
danwalmsley
@danwalmsley
Jan 12 2016 16:46
perhaps my binding is returning null for some reason and causing MarkContainerSelected to crash
Steven Kirk
@grokys
Jan 12 2016 16:47
still shouldn't cause a crash, sounds like a bug
what is the actual exception?
danwalmsley
@danwalmsley
Jan 12 2016 16:47
null reference exception
I just wondered if maybe me injecting it might be causing a problem since InitializeComponent will be called later than normal
maybe it doesnt matter though?
Steven Kirk
@grokys
Jan 12 2016 16:52
easy way to find out is to do a quick test project like you did for your other problem
danwalmsley
@danwalmsley
Jan 12 2016 20:03
@grokys tried to reproduce in the testapp without sucess.
iv got it to work in normal app
but if the property im binding content to is not initialized
it crashes
but the test app doesnt when uninitialized
Steven Kirk
@grokys
Jan 12 2016 20:03
hmm ok
danwalmsley
@danwalmsley
Jan 12 2016 20:04
not sure what the difference is
Steven Kirk
@grokys
Jan 12 2016 20:04
i'm just finishing something off but i should have chance to look later
danwalmsley
@danwalmsley
Jan 12 2016 20:06
ah it does happen in test app too
as long as its not the first tab!
Its CarouselPresenter.cs line 238
Nikita Tsukanov
@kekekeks
Jan 12 2016 20:10

but if the property im binding content to is not initialized

At some point OmniXAML haven't supported null values from MarkupExtension.ProvideValue

It can be somehow related
danwalmsley
@danwalmsley
Jan 12 2016 20:14
perhaps
hey does anyone have an idea how to accomplish this:
TabItems
some of the Tabs will be defined in xaml
and other from a bound collection?
is that possible?
Steven Kirk
@grokys
Jan 12 2016 20:22
no, i don't think that will ever be possible
how do i reproduce the error in test app?
danwalmsley
@danwalmsley
Jan 12 2016 20:36
I'll check into my fork
if you can pull from there?
I had to add a fair bit of setup code
@grokys pull from here:
VitalElement/Perspex@e04f04f
thats has the test app ready to repro
just run test app
and click on Content Injection tab
will crash immediately.
Steven Kirk
@grokys
Jan 12 2016 20:52
ah... ok, i see the problem
need to think about that a little
danwalmsley
@danwalmsley
Jan 12 2016 20:52
whats the cause?
Steven Kirk
@grokys
Jan 12 2016 21:08
a null item is getting added to the carousel presenter in the content part of the TabControl
usually null items are stripped out of ItemsControl items
but we can't strip them out here as then the content won't match the headers
danwalmsley
@danwalmsley
Jan 12 2016 21:09
ah ok
maybe they just need to be replaced with an empty <Grid> control?
Darnell Williams
@Seeker1437
Jan 12 2016 21:10
that might explain some of the ugliness in WPF then D:
Steven Kirk
@grokys
Jan 12 2016 21:11
why a <Grid>?
danwalmsley
@danwalmsley
Jan 12 2016 21:12
well anything empty
not necessarily a grid.
Steven Kirk
@grokys
Jan 12 2016 21:12
ah ok, yeah just a <Control> will do in that case