I am still trying to convert a WPF project to Avalonia and have issues with the window size. I already learned that there is no Auto so that I have to use NaN. Still the window size does not fit my datagrid:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:EndpointHelper.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="Auto" d:DesignHeight="350"
x:Class="EndpointHelper.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Width="NaN" Height="350"
Icon="/Assets/avalonia-logo.ico"
Title="EndpointHelper">
<Window.KeyBindings>
<KeyBinding Gesture="F5" Command="{Binding KeyDownEvent_F5Command}"/>
</Window.KeyBindings>
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel/>
</Design.DataContext>
<!-- <TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/> -->
<Grid>
<DockPanel Margin="5">
<Border DockPanel.Dock="Top" >
<Border>
<DataGrid x:Name="datagrid_information" ItemsSource="{Binding Informationdgm, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
IsReadOnly="True" AutoGenerateColumns="False" HeadersVisibility="None" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" BorderThickness="0.1" >
<DataGrid.Columns>
<DataGridTextColumn FontSize="12" Binding="{Binding Attribute}" Header="Attribute" Width="Auto"/>
<DataGridTextColumn FontSize="12" Binding="{Binding Value}" Header="Value" Width="Auto"/>
</DataGrid.Columns>
</DataGrid>
</Border>
</Border>
</DockPanel>
</Grid>
</Window>
In my understanding, the window width size should be the size of the DataGrid, but it is much wider.
In this example it should only be as width as the Last Refresh Time is.
Can someone please assist?
Thanks
Stephan