Windows has this beautiful control FlipView.
When I want to add it to my xaml page, VS can find it source (I've checked, Windows library is included into project). So I found suggestion to create own class which will be inherited from FlipView class. After I did it, VS said it can't find definition of <FlipView.ItemTemplate>. So what I am doing wrong?
Code which I've used to test FlipView
<FlipView x:Name="flipView1" Width="480" Height="270"
BorderBrush="Black" BorderThickness="1">
<FlipView.ItemTemplate>
<DataTemplate>
<Grid>
<Image Width="480" Height="270" Source="{Binding Image}" Stretch="UniformToFill"/>
<Border Background="#A5000000" Height="80" VerticalAlignment="Bottom">
<TextBlock Text="{Binding Name}" FontFamily="Segoe UI" FontSize="26.667"
Foreground="#CCFFFFFF" Padding="15,20"/>
</Border>
</Grid>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
FlipView is a Windows Store/Universal App only class.
The page you link to clearly states:
Requirements (Windows 10 device family)
Device family
Universal
and
Requirements (Windows 8.x and Windows Phone 8.x)
Minimum supported client
Windows 8 [Windows Store apps only]
If you want to have the same functionality in a WPF desktop application you will need to either find a third party control that does the same or write your own.
Related
My app is published in Windows Store now, but when I install it from the store, all of my custom images are missing. When I install via debugger from VisualStudio everything is fine. Is there maybe a missing resource note in appxmanifest for using custom images, by any chance?
Example:
<Button x:Name="myBtn" Grid.Row="0" Tapped="myBtn_Tapped" Style="{StaticResource ButtonStyleMenu}" BorderThickness="0" ClickMode="Press">
<StackPanel Orientation="Horizontal">
<Image x:Name="alert" Stretch="Fill" Source="ms-appx:///Assets/my/menu/btn.scale-100.png" Margin="10,0,0,0" Width="25" Height="25" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock x:Name="btnTxt" Text="ClickMe" FontSize="18" Foreground="White" Margin="10,0" VerticalAlignment="Center"/>
</StackPanel>
</Button>
You should not be looking for a qualified asset, like btn.scale-100.png. Instead, you should look for an unqualified asset like btn.png, and Windows will automatically load the right resource depending on the scale-factor of the OS.
This article does explain the concept at some depth: https://blogs.windows.com/buildingapps/2013/08/08/developing-world-ready-apps-in-xaml-part-2/
The case is really trivial: FontWeight's attribute for TextBlock does not work in Universal Store App. I have created sample project (Universal App), and in the WindowPhone's MainPage added TextBlock styled like that:
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize=20
FontWeight="Thin"
Text="Test text should be thin in runtime." />
In the designer everything looks fine, but when I deploy an app on a simulator/device, test text is not thinned! It's normal. Check out the screenshot:
As you can see, in the designer the text is perfectly thin (it's beautiful!). However in the running simulator text's weight is normal. Why's that? How can I workaround it? Thanks in advance for any help.
It works pretty well in WP8.0 Silverlight but in WP8.1 run time, you'll need to apply a <Style> to it as well. Like so
<Grid x:Name="ContentPanel">
<StackPanel>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="20" Text="Test text should be normal in runtime."/>
<!-- apply the a style like BodyTextBlockStyle -->
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="20"
Text="Test text should be thin in runtime."
FontWeight="Thin" Style="{StaticResource BodyTextBlockStyle}"/>
</StackPanel>
</Grid>
I am using VS Studio Express 2012 on my Windows 8 machine and developing Win8 Store App, using a trial and free account.
I am using a ListBox in my app and try to populate an image with some other stuffs from a collection class. The code snippets look like this:
MainPage.xaml
<ListBox x:Name="OwnerDraw" Width="600" HorizontalAlignment="Left" ItemsSource="{Binding Statuses}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Width="300" Height="400" Source="{Binding Path=photo.imageUrl}" Stretch="Uniform"/>
<TextBlock FontSize="36" Foreground="Navy" Text="{Binding Path=id}"/>
<TextBlock FontSize="24" Foreground="Red" Text="{Binding Path=created_at}" Margin="50,0,0,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The id/created_at field displayed fine. But can't see the image.
The photo.imageUrl is something like: http://www.rsywx.net/books/cover/01732.png. The access to that site is OK and not down. A working example is here for reference.
Any help will be highly appreciated.
UPDATE: It turns out to be working now. False alarm. Sorry!
I have a problem understanding one style definition in Windows 8 metro apps.
When you create a metro style application with VS, there is also a folder named
Common
created. Inside this folder there is file called
StandardStyles.xaml
Now the following snippet is from this file:
<!-- Grid-appropriate 250 pixel square item template as seen in the GroupedItemsPage and ItemsPage -->
<DataTemplate x:Key="Standard250x250ItemTemplate">
<Grid HorizontalAlignment="Left" Width="250" Height="250">
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding Image}" Stretch="UniformToFill"/>
</Border>
<StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/>
<TextBlock Text="{Binding Subtitle}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
</StackPanel>
</Grid>
</DataTemplate>
What I do not understand here is the static resource definition, e.g. for the Border
Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}"
It is not about how you work with templates and binding and resources.
Where is this ListViewItemPlaceholderBackgroundThemeBrush located?
Many thanks for your help.
Dimi
In Windows 8 customer preview you can find the file containing the resources' definition (including ListViewItemPlaceholderBackgroundThemeBrush) at:
C:\Program Files (x86)\Windows Kits\8.0\Include\winrt\xaml\design\themeresources.xaml
This is one of those incredibly frustrating things that should be in Microsoft's documentation, but isn't (yet).
ListViewItemPlaceholderBackgroundThemeBrush is one of the System Brush Resources. It's defined by the Metro "Light" or "Dark" theme (whichever you selected for your app).
You can see the full list of system brushes in Blend. (Unfortunately, I haven't found any way to enumerate them in code. There doesn't seem to be any programmatic way to inspect the theme resources.)
Here are some steps that will get you to the full list. (Of course, you can abbreviate the steps if you're already familiar with Blend.)
Open Expression Blend.
Create a new project, and select XAML (Windows Metro style) > Blank App (XAML) and click OK.
Click in the design surface to select the Grid. (In the "Objects and timeline" docked window in the lower-left, the "[Grid]" line will become highlighted.)
In the Properties docked window in the upper right, find the "Brush" category.
Right below where it says "Background: No brush", there's a row of five buttons. Click the rightmost button ("Brush resources").
The list of system brush resources will appear in the listbox.
I've made a small application using MDI but I want to make another one where there is only one main window and the main container changes or updates. I'm sure this can be done without creating multiple panels but I've been doing a bit of reading and I can't seem to find how can I do this.
If I understand you correctly you want to keep only one form. You can use tab control and switch between different pages, or create a set of user controls and then manage yourself what user control to show
For my scrum information radiator (full screen application for a big TV in portrait) I decided to use a set of controls from Actipro. I have multiple windows, but only one visible at a time. The user can use the arrow keys to "swipe" windows in and out just like they're used to do in smartphones.
The control used was the ZapPanel, as seen in my xaml below:
<ListBox x:Name="listBox" Grid.RowSpan="2" BorderThickness="0" Focusable="False" SelectionMode="Single"
SnapsToDevicePixels="True" VerticalContentAlignment="Top" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" Background="Black">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<views:ZapPanel AreChildrenWrapped="True" Orientation="Horizontal" AreLeavingElementsAnimated="True" Background="Black" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<StackPanel Orientation="Horizontal" Height="30" Margin="10" VerticalAlignment="Top" Opacity="0.5" >
<Button Click="PrevButtonClick">Prev</Button>
<Button Click="NextButtonClick">Next</Button>
</StackPanel>
</Grid>