Replies: 2 comments
-
I would use XAML whenever you can because its usually more concise and intuitive for accomplishing the same things. But everything that can be done in XAML can also be done in c# code, whereas the reverse isn't true. So it's an opinionated choice. There is no TreeView. If you want to render hierarchical data, I'd probably just use vertical For example: <Border BorderBrush="Red" BorderThickness="2" Background="rgb(241,241,241)" TextForeground="Black" MaxHeight="300">
<Border.Styles>
<Style TargetType="Expander" Name="TreeViewExpander">
<Setter Property="ExpanderButtonSize" Value="8" />
<Setter Property="ExpanderButtonCollapsedBackgroundBrush" Value="Transparent" />
<Setter Property="ExpanderButtonExpandedBackgroundBrush" Value="Transparent" />
<Setter Property="ExpanderButtonBorderThickness" Value="0" />
<Setter Property="ExpanderDropdownArrowColor" Value="Black" />
<Setter Property="Margin" Value="2" />
</Style>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="StackPanel" Name="TreeViewStackPanel">
<Setter Property="Orientation" Value="Vertical" />
<Setter Property="Margin" Value="30,0,0,0" />
</Style>
</Border.Styles>
<ScrollViewer>
<Expander StyleNames="TreeViewExpander" Header="Beverages">
<StackPanel StyleNames="TreeViewStackPanel">
<TextBlock Text="Water" />
<Expander StyleNames="TreeViewExpander" Header="Tea">
<StackPanel StyleNames="TreeViewStackPanel">
<TextBlock Text="Black Tea" />
<TextBlock Text="White Tea" />
<Expander StyleNames="TreeViewExpander" Header="Green Tea">
<StackPanel StyleNames="TreeViewStackPanel">
<TextBlock Text="Sencha" />
<TextBlock Text="Gyokuro" />
<TextBlock Text="Matcha" />
<TextBlock Text="Pi Lo Chun" />
</StackPanel>
</Expander>
</StackPanel>
</Expander>
<TextBlock Text="Coffee" />
</StackPanel>
</Expander>
</ScrollViewer>
</Border> In that example, I used an |
Beta Was this translation helpful? Give feedback.
-
Great, thank you very much. |
Beta Was this translation helpful? Give feedback.
-
Hi,
currently im experimenting with this MGUI and i like it.
I have 2 Questions:
Should i stick to UIFromCode or are there big benifits to switch to UIFromXML?
Is there a TreeView in here ? If not, what approch would be advisable for me to mimic one?
Beta Was this translation helpful? Give feedback.
All reactions