Avalonia invalidCastException

583 Views Asked by At

We're trying to built a UI with Avalonia for a project. One of our VM's needs to use MultiBinding, but it throws this message: "System.InvalidCastException: 'Unable to cast object of type 'Avalonia.Data.MultiBinding' to type 'Avalonia.Controls.IControl'.'". How do I come around this message?

<Grid ColumnDefinitions="Auto, Auto">
        <StackPanel Grid.Column="0">
            <Border Classes="Left">
                <ScrollViewer MaxHeight="400">
                    <ItemsControl Items="{Binding PublicationTypes}" Name="PubType">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Grid ColumnDefinitions="*,Auto,Auto">
                                    <TextBox Text="{Binding Name}" Grid.Column="0" Name="PubName" />
                  <MultiBinding>
                    <Binding ElementName="MainView"/>
                    <Binding Path="Name"/>
                  </MultiBinding>
                                    <Button Grid.Column="1" Classes="Options" Command="{Binding ElementName=MainView, Path=DataContext.EditPublicationType}" CommandParameter="{Binding ElementName=MainView, Path=DataContext.PublicationTypes}">
                                    <!-- CommandParameter="{Binding ElementName=MainView}-->
                                        <Image Source="avares://Zenref.Ava/Assets/options.ico" />
                                    </Button>
                                    <Button Grid.Column="2" Classes="Cross" Command="{Binding ElementName=MainView, Path=DataContext.DeletePublicationTypeCommand}" CommandParameter="{Binding Name}">
                                        <Image Source="avares://Zenref.Ava/Assets/cross.ico" />
                                    </Button>
                                </Grid>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>
            </Border>
        </StackPanel>
        <StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="50" Margin="20" VerticalAlignment="Top">
        <Border Width="250" Height="300" Padding="10">
            <StackPanel Orientation="Vertical" Spacing="3">
                <StackPanel Orientation="Horizontal" Spacing="10">
                    <TextBlock Text="Referencer importeret" Width="125"/>
                    <TextBlock Text=":"/>
                    <TextBlock Text="60000"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Spacing="10">
                    <TextBlock Text="Identificeret" Width="125"/>
                    <TextBlock Text=":"/>
                    <TextBlock Text="0"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Spacing="10">
                    <TextBlock Text="Uidentificeret" Width="125"/>
                    <TextBlock Text=":"/>
                    <TextBlock Text="0"/>
                </StackPanel>
            </StackPanel>
        </Border>
    </StackPanel>
        <Button Name="menuButton" Command="{Binding OpenSearchCriteriaCommand}" CommandParameter="{Binding ElementName=MainView}" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="100" Margin="10">Menu</Button>
        <Button Name="startButton" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="100" Margin="125,10">Start</Button>
        <Button Name="exportButton" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="100" Margin="10,10">Exporter</Button>
    </Grid>

We've tried looking through Avalonia's documentation and through stackoverflow, but we haven't found a similar problem.

0

There are 0 best solutions below