C
C#16mo ago
Mekasu0124

✅ placing styles in a separate folder

I'm going to attempt to create my first game using avalonia mvvm. It's not going to be like a video game, but moreso a text trivia game. I'm wanting to learn how to have a Styles folder with style files for each screen inside that folder. Let's say I have a HomeScreenView.axaml and a Styles/HomeScreenViewStyles.axaml. How would I use those styles from that style file in my view page?
1 Reply
Mekasu0124
Mekasu0124OP16mo ago
I found on stackoverflow that I use <StyleInclude Source="path_to_style_file.axaml" /> however, the examples they linked to which is someones github kind of throws me off a bit in my App.axaml file I have
<Application.Styles>
<StyleInclude Source="Styles/HomeScreenViewStyle.axaml" />
</Applcition.Styles>
<Application.Styles>
<StyleInclude Source="Styles/HomeScreenViewStyle.axaml" />
</Applcition.Styles>
and when I added a new item to the Styles folder, it gave me the pre-gen'd code
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>

<!-- Add Styles Here -->
</Styles>
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>

<!-- Add Styles Here -->
</Styles>
and I'm a bit confused how I use this to style my home screen oh nvm. I figured it out. thanks
Want results from more Discord servers?
Add your server