4. Labor segédanyagok
Fileok
background.jpg
Windows8Cookbook.pptx
Források
Snippet 01. PageHeaderTextBlockStyle
<Style x:Key="PageHeaderTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource HeaderTextBlockStyle}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Margin" Value="116,0,0,36"/>
</Style>
Snippet 02. WP Header
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Grid.Row="0">
<TextBlock Text="UNIVERSAL COOKBOOK" Style="{StaticResource ApplicationTitleTextBlockStyle}"/>
<TextBlock Text="Recipes" Style="{StaticResource PageHeaderTextBlockStyle}"/>
</StackPanel>
Snippet 03. WP PageHeaderTextBlockStyle, ApplicationTitleTextBlockStyle
<Style x:Key="PageHeaderTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource HeaderTextBlockStyle}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="Margin" Value="24,0,0,6"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
<Style x:Key="ApplicationTitleTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource TitleTextBlockStyle}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="FontWeight" Value="ExtraBold"/>
<Setter Property="Margin" Value="24,6,0,0"/>
<Setter Property="Padding" Value="0"/>
</Style>
Snippet 04. WP MainPage.xaml.cs HardwareButtonsOnBackPressed
private async void HardwareButtonsOnBackPressed(object sender, BackPressedEventArgs args)
{
args.Handled = true;
var dialog = new MessageDialog("Are you sure that you want to exit?", "Exit confirmation");
dialog.Commands.Add(new UICommand("Exit", command => Application.Current.Exit()));
dialog.Commands.Add(new UICommand("Cancel", command => { }));
dialog.DefaultCommandIndex = 0;
dialog.CancelCommandIndex = 1;
await dialog.ShowAsync();
}
Snippet 05. VariableSizedGridView
public class VariableSizedGridView : GridView
{
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
{
var supportItem = item as ISupportVariableSizedWrapGrid;
if (supportItem != null)
{
element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, supportItem.ColumnSpan);
element.SetValue(VariableSizedWrapGrid.RowSpanProperty, supportItem.RowSpan);
}
base.PrepareContainerForItemOverride(element, item);
}
}
Snippet 06. Win8 MainPage.xaml.cs PartialOnNavigatedTo
partial void PartialOnNavigatedTo(NavigationEventArgs e)
{
for (int i = 0; i < RecipeGroups.Count; i++)
{
var first = RecipeGroups[i].Recipes.First();
if (i % 2 == 0)
first.ColumnSpan = 2;
else
first.RowSpan = 2;
}
recipesViewSource.Source = RecipeGroups;
}
Snippet 07. Win8 MainPage.xaml RecipeHeaderTemplate
<DataTemplate x:Key="RecipeHeaderTemplate">
<Grid HorizontalAlignment="Left" Width="250" Height="250">
<Image Source="{Binding BackgroundImage}" Stretch="UniformToFill" />
<Border VerticalAlignment="Bottom" Background="#AA000000">
<TextBlock Text="{Binding Title}" Style="{StaticResource TitleTextBlockStyle}" Height="30" Margin="15,0,15,0"/>
</Border>
</Grid>
</DataTemplate>