我正在努力适应新平台,但出于某种原因,在我多次运行应用程序后,它不会显示它的元素。就像我添加另一个元素一样,它不会显示任何内容。我尝试删除所有内容并从头开始,但它也做了同样的事情。即使我将主题更改为黑暗,应用仍然是空白,而不是显示至少一个元素。编译器也没有显示错误。我的主页是:
<Page
x:Class="WDRPCIV.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WDRPCIV"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationForegroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<RelativePanel>
<Button Width="40" Height="40" Background="{ThemeResource SystemControlForegroundAccentBrush}" Name="RootHamburger" FontFamily="Segoe MDL2 Assets" Content="" FontSize="20" Click="EvenimentMeniu"/>
<TextBlock x:Name="textBlock" Text="YOLOSWAG" FontSize="16" Margin="50,13,0,0"/>
</RelativePanel>
<SplitView Name="ListaNavigare" Grid.Row="1" DisplayMode="CompactOverlay" OpenPaneLength="200" CompactPaneLength="40" HorizontalAlignment="Left">
<SplitView.Pane>
<ListBox SelectionMode="Single" Name="Iconite" SelectionChanged="SchimbareFereastra">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="18" Text=""></TextBlock>
<TextBlock Text="Selectare Categorie" FontSize="14" Margin="20,0,0,0"></TextBlock>
</StackPanel>
</ListBoxItem>
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="18" Text=""></TextBlock>
<TextBlock Text="Incepere Chestionar" FontSize="14" Margin="20,0,0,0"></TextBlock>
</StackPanel>
</ListBoxItem>
<ListBoxItem>
<StackPanel Orientation="Horizontal" GotFocus="StackPanel_GotFocus">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="18" Text=""></TextBlock>
<TextBlock Text="Despre" FontSize="14" Margin="20,0,0,0"></TextBlock>
</StackPanel>
</ListBoxItem>
</ListBox>
</SplitView.Pane>
</SplitView>
</Grid>
答案 0 :(得分:1)
由于您的背景为Black
而您的字体前景也为黑色,因此该应用仍为空白。其次,为了更好地利用Splitview,你需要先在汉堡上做两件事点击你需要打开splitview面板,如果它已关闭,并在Splitview.Content
下定义你的内容。
这是更新的XAML复制和粘贴,您将找到差异。
<Grid Background="{ThemeResource ApplicationForegroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<RelativePanel>
<Button Width="40" Height="40" Background="{ThemeResource SystemControlForegroundAccentBrush}" Name="RootHamburger" FontFamily="Segoe MDL2 Assets" Content="" FontSize="20" Click="EvenimentMeniu"/>
<TextBlock x:Name="textBlock" Text="YOLOSWAG" Foreground="White" FontSize="16" Margin="50,13,0,0"/>
</RelativePanel>
<SplitView Name="ListaNavigare" Grid.Row="1" DisplayMode="CompactOverlay" OpenPaneLength="200" CompactPaneLength="40" HorizontalAlignment="Left">
<SplitView.Pane>
<ListBox SelectionMode="Single" Name="Iconite" >
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="18" Text=""></TextBlock>
<TextBlock Text="Selectare Categorie" FontSize="14" Margin="20,0,0,0"></TextBlock>
</StackPanel>
</ListBoxItem>
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="18" Text=""></TextBlock>
<TextBlock Text="Incepere Chestionar" FontSize="14" Margin="20,0,0,0"></TextBlock>
</StackPanel>
</ListBoxItem>
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="18" Text=""></TextBlock>
<TextBlock Text="Despre" FontSize="14" Margin="20,0,0,0"></TextBlock>
</StackPanel>
</ListBoxItem>
</ListBox>
</SplitView.Pane>
<SplitView.Content>
<Grid Background="Green" Width="550" >
<TextBlock Text="Your Content"/>
</Grid>
</SplitView.Content>
</SplitView>
</Grid>
还要确保在汉堡按钮的点击事件内部添加了代码以打开窗格。
private void EvenimentMeniu(object sender, RoutedEventArgs e)
{
ListaNavigare.IsPaneOpen = true;
}