question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Something's wrong with Views.grid

See original GitHub issue

I tried modifying your counter example code to use a grid instead of a dock panel:

    let view (state : CounterState) (dispatch) : View =
        Views.grid [
            Attrs.rowDefinitions (RowDefinitions "1*,1*")
            Attrs.columnDefinitions (ColumnDefinitions "1*, 1*")
            Attrs.children [
                Views.button [
                    // Attrs.dockPanel_dock Dock.Bottom
                    Attrs.grid_row 1
                    Attrs.grid_column 0
                    Attrs.onClick (fun sender args -> dispatch Decrement)
                    Attrs.content "-"
                ]
                Views.button [
                    // Attrs.dockPanel_dock Dock.Bottom
                    Attrs.grid_row 1
                    Attrs.grid_column 1
                    Attrs.onClick (fun sender args -> dispatch Increment)
                    Attrs.content "+"
                ]
                Views.textBlock [
                    // Attrs.dockPanel_dock Dock.Top
                    Attrs.grid_row 0
                    Attrs.grid_column 0
                    Attrs.grid_columnSpan 2
                    Attrs.fontSize 48.0
                    Attrs.verticalAlignment VerticalAlignment.Center
                    Attrs.horizontalAlignment HorizontalAlignment.Center
                    Attrs.text (string state.count)
                ]
            ]
        ]

The state is not updated anymore - the update function always gets the initial state for some reason.

The issue is with these two lines:

            Attrs.rowDefinitions (RowDefinitions "1*,1*")
            Attrs.columnDefinitions (ColumnDefinitions "1*, 1*")

I get this error:

testafb3 Error: 0 : Unable to process the message: Increment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotSupportedException: Reassigning RowDefinitions not yet implemented.
   at Avalonia.Controls.Grid.set_RowDefinitions(RowDefinitions value) in D:\a\1\s\src\Avalonia.Controls\Grid.cs:line 131
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at Avalonia.FuncUI.VirtualDom.Patcher.AttrPatcher.setValue@373(IControl view, PropertyAttrDelta attr, Object value)
   at Avalonia.FuncUI.VirtualDom.Patcher.AttrPatcher.patchProperty(IControl view, PropertyAttrDelta attr)
   at Avalonia.FuncUI.VirtualDom.Patcher.patch(IControl view, ViewDelta viewElement)
   at Avalonia.FuncUI.Hosts.HostWindow.Avalonia-FuncUI-Hosts-IViewHost-UpdateView(View viewElement)
   at Avalonia.FuncUI.Elmish.Program.withHost@11.Invoke(model state, FSharpFunc`2 dispatch)
   at Elmish.ProgramModule.dispatch@132.Invoke(msg msg) in /Users/eugene/sources/elmish/elmish/src/program.fs:line 142

Is there a way to avoid this issue?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JaggerJocommented, Aug 25, 2019

will be fixed in ‘v-next’.

0reactions
JaggerJocommented, Oct 13, 2019

Custom equality comparisons need to be added to FuncUI. I’m currently super busy so if the workaround works for you I’ll not hurry to fix it.

If you actually are using it or really want it either tell me and I’ll do my best to fix it faster OR fix it and make a PR 😉.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Something's wrong with Views.grid · Issue #14
I tried modifying your counter example code to use a grid instead of a dock panel: let view (state : CounterState) (dispatch) :...
Read more >
views grid columns are not responsive [#2988457]
I find that grids do not behave responsively on the site. I noticed when I made a views block with two grid columns...
Read more >
Figure out how to handle views grid in Olivero
One option could be to deprecate the grid display entirely. I assume almost everyone who is displaying views in a grid-like layout is...
Read more >
View Options, Grid/List view stuck - Apple Community
View Options, Grid/List view stuck · Open the Settings app on your Apple Watch. · Tap App View, then tap Grid View or...
Read more >
9 Biggest Mistakes with CSS Grid - YouTube
It's easy to make lots of mistakes with a new technology, especially something that's as big of a change from the past as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found