WinRT Slider draw secondary progress on top of primary progress? - winrt-xaml

I want to build custom slider with secondary progress on top of the primary progress chosen by the customer.
something like that in android: Changing Android SeekBar to draw secondary progress on top of primary progress?
Thanks

Like this:
<Grid VerticalAlignment="Top">
<ProgressBar Height="2" MinHeight="2"
Margin="0,-6,0,0" VerticalAlignment="Center"
Foreground="Silver" IsHitTestVisible="False"
Value="65" />
<Slider Background="Transparent" Value="35" />
</Grid>
Looks like this:
Sort of like the YouTube seek bar, right?
Best of luck!

Related

Content inside layout panel not scrolling

Say I have a simple Windows 10 UWP app
<Page
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- etc -->
>
<Grid>
<ListView>
<TextBlock Text="Sample text"/>
<TextBlock Text="Sample text"/>
<TextBlock Text="Sample text"/>
<!-- & many more -->
</ListView>
</Grid>
</Page>
The large number of ListView items causes it to overflow and scroll, as expected:
However, if I need to add another control as a sibling of the ListView, like so (replacing the Grid with a StackPanel for simplicity)
<Page...>
<StackPanel>
<ListView>
<TextBlock Text="Sample text"/>
<TextBlock Text="Sample text"/>
<TextBlock Text="Sample text"/>
...
</ListView>
<StackPanel>
<TextBlock Text="StackPanel at the bottom"/>
<Button Content="Click me"/>
</StackPanel>
</StackPanel>
</Page>
then the scrollbar disappears and the ListView isn't scrollable anymore. The content just gets clipped / cut off past the bottom of the window.
What's going on here and how can I make it scroll again?
The key to this is the ScrollViewer control. The reason ListViews and GridViews can scroll in the first place is because they have a ScrollViewer built in.
When you place a ListView inside a parent layout panel (e.g. a StackPanel or a Grid row), if the ListView height is greater than the viewport, the parent panel becomes the full height of the ListView. But StackPanel doesn't implement ScrollViewer so it can't scroll, and you end up with a StackPanel extending off the bottom edge of the viewport.
The fix is simple: put the parent layout panel in question inside a ScrollViewer
<Page...>
<ScrollViewer VerticalScrollBarVisibility="Auto"> <!--default is "Visible"-->
<StackPanel>
<ListView>
<TextBlock Text="Sample text"/>
<TextBlock Text="Sample text"/>
<TextBlock Text="Sample text"/>
...
</ListView>
<StackPanel>
<TextBlock Text="StackPanel at the bottom"/>
<Button Content="Click me"/>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Page>
ScrollViewer API reference - MSDN
Going to add more context to binaryfunt's answer: It depends on the layout logic of the panel you're using!
To note beforehand: ListView internally has it's own ScrollViewer by default.
When laying out it's children, a Grid will typically tell its children they should fit inside the bounds the grid. In the case of the ListView, it's happy to do this, and it's own internal ScrollViewer handles it's children scrolling.
StackPanel on the other hand tells its children they have virtually infinite space to layout in in it's stacking direction - so your ListView has no idea it has to constrain itself to the height of your StackPanel because the StackPanel does not tell it do so and so the ListView never needs to use it's own ScrollViewer as it thinks it has infinite space.
Now, put a StackPanel in a ScrollViewer by itself doesn't help - if you put that ScrollViewer inside a StackPanel you have the same problem as the ListView does - it thinks it has infinite space and so never needs to scroll it's content. But, put the ScrollViewer in a Grid and the grid will give the ScrollViewer a defined size to layout in, and so anything inside the ScrollViewer will now scroll if it get's too big.
Put a ListView inside this StackPanel inside this ScrollViewer? The ListView still thinks it has infinite space and so never needs to use its own scroller, BUT it's also disables and virtualization and performance enhancements the ListView would normally have, as they rely on it's interal ScrollViewer actually being put a too use.
(binaryfunt's XAML answer will work.)

Is it possible to combine an ImageBrush with a LinearGradientBrush in UWP

I'm building a Planning Poker UWP app for fun. I can style the poker cards (currently implemented as Buttons, via the Background property) using either an ImageBrush or a LinearGradientBrush without any issue, but obviously I can only set one type of brush to that property.
I'd like to style the card with an image, which then had another brush (e.g. a LinearGradientBrush) over-layed on top, this other brush would naturally have some degree of transparency so that parts of the image could show through.
How would you do that?
For the actual poker card that the user sees - I can re-implement that fairly easily using a different control type (e.g. a UserControl that combined several controls, each with their own background) but there are other instances of use (i.e. showing a list of the available styles), so I wanted to see if there way another way before looking into writing a custom UserControl.
Button is a content control, you can put other xaml controls in the button's content, and set LinearGradientBrush for them. For example,you can set ImageBrush for the button's background property, in the meanwhile set LinearGradientBrush for a Rectangle inline.
I'd like to style the card with an image, which then had another brush (e.g. a LinearGradientBrush) over-layed on top, this other brush would naturally have some degree of transparency so that parts of the image could show through.
To meet your requirement, I wrote a code example as follows:
<Button x:Name="BtnPoker" Padding="0">
<Rectangle Width="200"
Height="300"
Margin="0"
Opacity="0.4">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0.0" Color="Yellow" />
<GradientStop Offset="0.25" Color="Red" />
<GradientStop Offset="0.75" Color="Blue" />
<GradientStop Offset="1.0" Color="LimeGreen" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Button.Background>
<ImageBrush ImageSource="Assets\caffe.jpg" />
</Button.Background>
</Button>
And the result:

Any idea to create masked text box in uwp

Currently I got a requirement to implement a control something like traditional masked text box. But unfortunately there is no first party control (some third party paid control is available like Component 1) available in uwp. If anybody has any idea to create the same please share.
You can make a TextBox background transparent and have a TextBlock behind it with your watermark text. Bind the visibility to the TextBox Text.IsEmpty property using a BooleanToVisibilityConverter
<Grid Grid.Row="0" Margin="5" Background="White">
<TextBlock VerticalAlignment="Center" Margin="3"
Foreground="SteelBlue"
Visibility="{Binding ElementName=MyTextBox, Path=Text.IsEmpty, Converter={StaticResource BooleanToVisibilityConverter}}">Type in here...</TextBlock>
<TextBox Background="Transparent"
x:Name="MyTextBox"/>
</Grid>
In your resources:
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
Have a look at PlaceHolderText Property on TextBox control.

win10 app - animating in a new item at top of list

I'm making a news feed app, which periodically adds new content to the top of the list. When I check for new items, there might be dozens or just one. What I'd like is for the oldest of the new items to peek into view so they can continue scrolling up for newer stories.
Sadly this doesn't come for free with the platform. However whats interesting is that it does come for free at the bottom of the list. If you add items to the bottom of the list they peek in properly with a nice animation. If you add items to the top of the list they just blink into place.
Workarounds available? I'm feeling this is more of a platform bug - I'm setting KeepItemsInView but if I'm at the top of the list it doesn't keep the item I'm looking at in view.
Repro video: http://1drv.ms/1PP8AZz
Full source: http://1drv.ms/1PP8FfT
<ListView Grid.Row="1" ItemsSource="{x:Bind Items}" Padding="0,100,0,100">
<ListView.ItemTemplate>
<DataTemplate >
<Grid Margin="10">
<Image Source="{Binding}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Vertical" ItemsUpdatingScrollMode="KeepItemsInView" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>

Image alignment issues in databound Pivot control

I'm using a pivot control and binding my collection of images to it. I'm having a problem with alignment of the photos.
If all the photos are landscape, they align at the top, and I am unable to use the gesture control anywhere below the photo.
If they are a mix of portrait/landscape, the images appear ok, until I rotate the device. Then the portrait images are extremely zoomed in, and the landscape images are located half way down the screen.
I'm new to WP7 development and the layout is still pretty foreign to me. Any assistance would be appreciated. I'm sure someone has to have created a basic photo viewer like this....
<controls:Pivot Name="photoPivot" Loaded="photoPivot_Loaded"
ItemsSource="{Binding _photos}">
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<Grid Height="1" Width="1"/>
</DataTemplate>
</controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate>
<DataTemplate>
<Image VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Source="{Binding photo_link}" />
</DataTemplate>
</controls:Pivot.ItemTemplate>
<controls:Pivot.ItemContainerStyle>
<Style TargetType="controls:PivotItem">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
</Style>
</controls:Pivot.ItemContainerStyle>
</controls:Pivot>
I was able to solve this by removing all height/width definitions from the grid in the data template and the LayoutRoot grid.

Resources