我的 windows phone 应用程序在启动前一直崩溃,到目前为止我只完成了 ui
My windows phone app keeps crashing before startup and I have only done the ui so far
我一直在尝试为 windows phone 8.1 制作一个应用程序,我决定使用集线器模板。我已经设计了我的应用程序,现在当我尝试 运行 时,每次都会抛出异常。这让我非常困惑,因为我用自己的控件进行了所有设计并且没有编写任何我自己的 xaml。但是我得到 windows.UI.Xaml.UnhandledException 任何帮助都非常好,这是我为 windows phone 制作的第一批应用程序之一,所以我对这个主题还很陌生。这里是xaml如果有用的话
<Page
x:Class="AttemptAtHub.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AttemptAtHub"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<ControlTemplate x:Key="HubSectionControlTemplate1" TargetType="HubSection">
<Grid>
<TextBox x:Name="tbHours" HorizontalAlignment="Left" Margin="8,160,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" Width="87" PlaceholderText=" hrs"/>
<TextBox x:Name="tbMinutes" HorizontalAlignment="Left" Margin="109,160,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" PlaceholderText=" min" Width="87"/>
<TextBlock x:Name="tblk_" HorizontalAlignment="Left" TextWrapping="Wrap" Text=":" VerticalAlignment="Top" FontSize="21.333" Margin="101,163,0,0"/>
<TextBlock HorizontalAlignment="Left" Margin="8,205,0,0" TextWrapping="Wrap" Text="Work date" VerticalAlignment="Top" FontSize="13.333"/>
<DatePicker HorizontalAlignment="Left" Margin="8,216,0,0" VerticalAlignment="Top" Width="133"/>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="" Margin="132,213,0,0" VerticalAlignment="Top" Height="59"/>
<TextBlock x:Name="hdrAddHours" HorizontalAlignment="Left" Margin="20,110,0,0" Style="{StaticResource ControlHeaderTextBlockStyle}" TextWrapping="Wrap" Text="Add Hours" VerticalAlignment="Top"/>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="HubSectionControlTemplate2" TargetType="HubSection">
<Grid>
<TextBlock x:Name="hdrWage" HorizontalAlignment="Left" Margin="20,95,0,0" Style="{StaticResource ControlHeaderTextBlockStyle}" TextWrapping="Wrap" Text="Wage" VerticalAlignment="Top" Foreground="White" FontSize="18.667"/>
<TextBlock HorizontalAlignment="Left" Margin="8,150,0,0" TextWrapping="Wrap" Text="Working hour rate" VerticalAlignment="Top" FontSize="13.333"/>
<TextBlock HorizontalAlignment="Left" Margin="8,175,0,0" TextWrapping="Wrap" Text="$" VerticalAlignment="Top" FontSize="21.333"/>
<TextBox x:Name="tbWage" HorizontalAlignment="Left" Margin="26,170,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" PlaceholderText=" 0.00" Width="89"/>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="" Margin="109,159,0,0" VerticalAlignment="Top"/>
</Grid>
</ControlTemplate>
</Page.Resources>
<Grid>
<Hub x:Name="Hub" Header="Hours+" Background="{ThemeResource PhoneAccentBrush}">
<HubSection x:Name="sctnAddHours" Template="{StaticResource HubSectionControlTemplate1}" Header="Add Hours">
<DataTemplate>
<Grid/>
</DataTemplate>
</HubSection>
<HubSection x:Name="sctnExpenses" Header="AddExpenses">
<HubSection.Resources>
<ControlTemplate x:Key="HubSectionControlTemplate2" TargetType="HubSection">
<Grid>
<TextBlock x:Name="hdrAddExpenses" HorizontalAlignment="Left" Margin="20,110,0,0" Style="{StaticResource ControlHeaderTextBlockStyle}" TextWrapping="Wrap" Text="Add Expenses" VerticalAlignment="Top"/>
<TextBlock x:Name="tblk_" HorizontalAlignment="Left" Margin="8,156,0,0" TextWrapping="Wrap" Text="$" VerticalAlignment="Top" FontSize="21.333"/>
<TextBox x:Name="tbExpense" HorizontalAlignment="Left" Margin="30,150,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" PlaceholderText=" 0.00" Width="89"/>
<TextBlock HorizontalAlignment="Left" Margin="8,200,0,0" TextWrapping="Wrap" Text="Expense date" VerticalAlignment="Top" FontSize="13.333"/>
<DatePicker HorizontalAlignment="Left" Margin="8,215,0,0" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="8,270,0,0" TextWrapping="Wrap" Text="Expense date" VerticalAlignment="Top" FontSize="13.333"/>
<TextBox x:Name="tbNotes" HorizontalAlignment="Left" Margin="8,290,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="260"/>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="" Margin="255,277,0,0" VerticalAlignment="Top"/>
</Grid>
</ControlTemplate>
</HubSection.Resources>
<HubSection.Template>
<StaticResource ResourceKey="HubSectionControlTemplate2"/>
</HubSection.Template>
<DataTemplate>
<Grid/>
</DataTemplate>
</HubSection>
<HubSection x:Name="sctnWage" Header="Set wage" Height="640" Template="{StaticResource HubSectionControlTemplate2}">
<DataTemplate>
<Grid/>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
</Page>
再次感谢您的帮助。
您正在替换 HubSection 的模板。
HubSection本身的ControlTemplate通过设置
<HubSection Template="{...}">...</HubSection>
此模板需要在其根元素上具有名称为 "WrappingTransform" 的 CompositeTransform,以便 Hub 控件正常工作。
您真的只想设置 HubSections 子 DataTemplate。
<HubSection Header="Add Hours">
<DataTemplate>...</DataTemplate>
</HubSection>
HubSection 的内容是一个 DataTemplate 可能有点令人困惑,但请记住,这是内容 属性(也就是 HubSection 内部的内容)而不是模板 属性(又名 HubSection 本身的外观、边框、间距等)您要修改。
我一直在尝试为 windows phone 8.1 制作一个应用程序,我决定使用集线器模板。我已经设计了我的应用程序,现在当我尝试 运行 时,每次都会抛出异常。这让我非常困惑,因为我用自己的控件进行了所有设计并且没有编写任何我自己的 xaml。但是我得到 windows.UI.Xaml.UnhandledException 任何帮助都非常好,这是我为 windows phone 制作的第一批应用程序之一,所以我对这个主题还很陌生。这里是xaml如果有用的话
<Page
x:Class="AttemptAtHub.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AttemptAtHub"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<ControlTemplate x:Key="HubSectionControlTemplate1" TargetType="HubSection">
<Grid>
<TextBox x:Name="tbHours" HorizontalAlignment="Left" Margin="8,160,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" Width="87" PlaceholderText=" hrs"/>
<TextBox x:Name="tbMinutes" HorizontalAlignment="Left" Margin="109,160,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" PlaceholderText=" min" Width="87"/>
<TextBlock x:Name="tblk_" HorizontalAlignment="Left" TextWrapping="Wrap" Text=":" VerticalAlignment="Top" FontSize="21.333" Margin="101,163,0,0"/>
<TextBlock HorizontalAlignment="Left" Margin="8,205,0,0" TextWrapping="Wrap" Text="Work date" VerticalAlignment="Top" FontSize="13.333"/>
<DatePicker HorizontalAlignment="Left" Margin="8,216,0,0" VerticalAlignment="Top" Width="133"/>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="" Margin="132,213,0,0" VerticalAlignment="Top" Height="59"/>
<TextBlock x:Name="hdrAddHours" HorizontalAlignment="Left" Margin="20,110,0,0" Style="{StaticResource ControlHeaderTextBlockStyle}" TextWrapping="Wrap" Text="Add Hours" VerticalAlignment="Top"/>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="HubSectionControlTemplate2" TargetType="HubSection">
<Grid>
<TextBlock x:Name="hdrWage" HorizontalAlignment="Left" Margin="20,95,0,0" Style="{StaticResource ControlHeaderTextBlockStyle}" TextWrapping="Wrap" Text="Wage" VerticalAlignment="Top" Foreground="White" FontSize="18.667"/>
<TextBlock HorizontalAlignment="Left" Margin="8,150,0,0" TextWrapping="Wrap" Text="Working hour rate" VerticalAlignment="Top" FontSize="13.333"/>
<TextBlock HorizontalAlignment="Left" Margin="8,175,0,0" TextWrapping="Wrap" Text="$" VerticalAlignment="Top" FontSize="21.333"/>
<TextBox x:Name="tbWage" HorizontalAlignment="Left" Margin="26,170,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" PlaceholderText=" 0.00" Width="89"/>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="" Margin="109,159,0,0" VerticalAlignment="Top"/>
</Grid>
</ControlTemplate>
</Page.Resources>
<Grid>
<Hub x:Name="Hub" Header="Hours+" Background="{ThemeResource PhoneAccentBrush}">
<HubSection x:Name="sctnAddHours" Template="{StaticResource HubSectionControlTemplate1}" Header="Add Hours">
<DataTemplate>
<Grid/>
</DataTemplate>
</HubSection>
<HubSection x:Name="sctnExpenses" Header="AddExpenses">
<HubSection.Resources>
<ControlTemplate x:Key="HubSectionControlTemplate2" TargetType="HubSection">
<Grid>
<TextBlock x:Name="hdrAddExpenses" HorizontalAlignment="Left" Margin="20,110,0,0" Style="{StaticResource ControlHeaderTextBlockStyle}" TextWrapping="Wrap" Text="Add Expenses" VerticalAlignment="Top"/>
<TextBlock x:Name="tblk_" HorizontalAlignment="Left" Margin="8,156,0,0" TextWrapping="Wrap" Text="$" VerticalAlignment="Top" FontSize="21.333"/>
<TextBox x:Name="tbExpense" HorizontalAlignment="Left" Margin="30,150,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" InputScope="Number" PlaceholderText=" 0.00" Width="89"/>
<TextBlock HorizontalAlignment="Left" Margin="8,200,0,0" TextWrapping="Wrap" Text="Expense date" VerticalAlignment="Top" FontSize="13.333"/>
<DatePicker HorizontalAlignment="Left" Margin="8,215,0,0" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="8,270,0,0" TextWrapping="Wrap" Text="Expense date" VerticalAlignment="Top" FontSize="13.333"/>
<TextBox x:Name="tbNotes" HorizontalAlignment="Left" Margin="8,290,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="260"/>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="" Margin="255,277,0,0" VerticalAlignment="Top"/>
</Grid>
</ControlTemplate>
</HubSection.Resources>
<HubSection.Template>
<StaticResource ResourceKey="HubSectionControlTemplate2"/>
</HubSection.Template>
<DataTemplate>
<Grid/>
</DataTemplate>
</HubSection>
<HubSection x:Name="sctnWage" Header="Set wage" Height="640" Template="{StaticResource HubSectionControlTemplate2}">
<DataTemplate>
<Grid/>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
</Page>
再次感谢您的帮助。
您正在替换 HubSection 的模板。
HubSection本身的ControlTemplate通过设置
<HubSection Template="{...}">...</HubSection>
此模板需要在其根元素上具有名称为 "WrappingTransform" 的 CompositeTransform,以便 Hub 控件正常工作。
您真的只想设置 HubSections 子 DataTemplate。
<HubSection Header="Add Hours">
<DataTemplate>...</DataTemplate>
</HubSection>
HubSection 的内容是一个 DataTemplate 可能有点令人困惑,但请记住,这是内容 属性(也就是 HubSection 内部的内容)而不是模板 属性(又名 HubSection 本身的外观、边框、间距等)您要修改。