{"id":4797,"date":"2023-01-09T18:00:31","date_gmt":"2023-01-09T17:00:31","guid":{"rendered":"https:\/\/ekiwi.de\/?p=4797"},"modified":"2023-01-09T18:00:32","modified_gmt":"2023-01-09T17:00:32","slug":"avaloniaui-datagrid-wird-nicht-angezeigt","status":"publish","type":"post","link":"https:\/\/ekiwi.de\/index.php\/4797\/avaloniaui-datagrid-wird-nicht-angezeigt\/","title":{"rendered":"AvaloniaUI  &#8211; DataGrid wird nicht angezeigt"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Inhalt<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ekiwi.de\/index.php\/4797\/avaloniaui-datagrid-wird-nicht-angezeigt\/#Paket_hinzufuegen\" >Paket hinzuf\u00fcgen<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ekiwi.de\/index.php\/4797\/avaloniaui-datagrid-wird-nicht-angezeigt\/#Styles_hinzufuegen\" >Styles hinzuf\u00fcgen<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ekiwi.de\/index.php\/4797\/avaloniaui-datagrid-wird-nicht-angezeigt\/#Spaltendefinition\" >Spaltendefinition<\/a><\/li><\/ul><\/nav><\/div>\n<p>DataGrid mit AvaloniaUI funktioniert nicht.<\/p>\n<p><!--more--><\/p>\n<p>Ich hatte das Problem, dass die DataGrid Komponente in meiner Anwendung nicht auftauchte. Ich habe das DataGrid zu einem Grid hinzugef\u00fcgt, aber nach dem Ausf\u00fchren des Programms war nichts zu sehen. Es gab auch keinen Fehler beim Kompilieren.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2023\/01\/grid_1.png\" alt=\"\" width=\"576\" height=\"122\" class=\"alignnone size-full wp-image-4798\" srcset=\"\/wp-content\/uploads\/2023\/01\/grid_1.png 576w, \/wp-content\/uploads\/2023\/01\/grid_1-300x64.png 300w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/p>\n<p>Wie kann man das beheben?<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Paket_hinzufuegen\"><\/span>Paket hinzuf\u00fcgen<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Als erstes muss das NuGet-Paket der DataGrid-Komponente zum Projekt hinzugef\u00fcgt werden. Standardm\u00e4\u00dfig ist das DataGrid nicht verf\u00fcgbar. Es ist \u00fcber eine transitive Abh\u00e4ngigkeit \u00fcber das Paket &#8222;Avalonia.Diagnostics&#8220; verf\u00fcgbar. Dadurch l\u00e4uft es im Debug-Modus, aber nicht im Release-Modus.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2023\/01\/grid_2.png\" alt=\"\" width=\"360\" height=\"228\" class=\"alignnone size-full wp-image-4800\" srcset=\"\/wp-content\/uploads\/2023\/01\/grid_2.png 360w, \/wp-content\/uploads\/2023\/01\/grid_2-300x190.png 300w\" sizes=\"auto, (max-width: 360px) 100vw, 360px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Styles_hinzufuegen\"><\/span>Styles hinzuf\u00fcgen<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Danach m\u00fcssen Sie der Anwendung die richtigen Stile f\u00fcr das Gitter hinzuf\u00fcgen. Beispiele sind <a href=\"https:\/\/docs.avaloniaui.net\/docs\/controls\/datagrid\" rel=\"noopener\" target=\"_blank\">in der Dokumentation zu finden<\/a>.<\/p>\n<p>In meinem Fall musste ich die Stile f\u00fcr das Thema &#8222;Fluent&#8220; hinzuf\u00fcgen.<\/p>\n<pre>&lt;Application.Styles&gt; \r\n&lt;FluentTheme Mode=&quot;Light&quot;\/&gt; \r\n&lt;StyleInclude Source=&quot;avares:\/\/Avalonia.Controls.DataGrid\/Themes\/Fluent.xaml&quot;\/&gt; \r\n&lt;\/Application.Styles&gt; <\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Spaltendefinition\"><\/span>Spaltendefinition<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Es wurde immer noch nichts angezeigt. Ich fand heraus, dass ich die Spaltendefinitionen definieren musste. Entweder, indem ich die Spalten automatisch generiere oder indem ich sie manuell definiere.<\/p>\n<pre>\r\nAutoGenerateColumns=\"True\"\r\n<\/pre>\n<p>Anschlie\u00dfend wurde das DataGrid endlich angezeigt.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2023\/01\/grid_3.png\" alt=\"\" width=\"799\" height=\"137\" class=\"alignnone size-full wp-image-4802\" srcset=\"\/wp-content\/uploads\/2023\/01\/grid_3.png 799w, \/wp-content\/uploads\/2023\/01\/grid_3-300x51.png 300w, \/wp-content\/uploads\/2023\/01\/grid_3-768x132.png 768w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><\/p>","protected":false},"excerpt":{"rendered":"<p>DataGrid mit AvaloniaUI funktioniert nicht.<\/p>\n","protected":false},"author":1,"featured_media":2260,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[13],"tags":[190],"class_list":["post-4797","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programmierung","tag-c"],"_links":{"self":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/4797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/comments?post=4797"}],"version-history":[{"count":0,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/4797\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media\/2260"}],"wp:attachment":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media?parent=4797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/categories?post=4797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/tags?post=4797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}