I want to display list of items in my Metro applications. And I want to just display them. I don't want any kind selection, mouse-over, keyboard control, or animation effects.
The items will be displayed with ItemTemplate, the list will be data-bound and I want scrolling (both vertical and horizontal).
What would be the simplest way to do this? The ListView has lots of defaults, that make "simply displaying" items a heroic task.
The ListView can get rid of almost everything you want by setting SelectionMode="None" and IsHitTestVisible="False". This will give you no selection or highlight of any elements with mouse or keyboard. You will still get scrolling and supporting interactions for scrolling. You will still get animations, however.
Otherwise, you will probably have to look at using an ItemsControl and ScrollViewer to get the effect you want.
Use the ItemsControl in the first instance. You add your data template as you desire and use the ItemsPanel control to apply your layout. For example, the StackPanel below allows the orientation to switch to horizontal.
<ItemsControl ItemsSource="{Binding Users}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding ImageUri}" Width="40" Height="40" Margin="5" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Related
How to handle the events when someone clicks(mouse click) on the violet color space around the elements ?
Putting a general onclick on the container is overriding the individual item behaviors (they all have their internal onclick handlers). Any other way to solve this ?
Edit:
<Grid onClick={ClickHandler} container direction="row">
<Grid item>
// Filter Screen that has buttons, checkboxes
</Grid>
<Grid item>
............
</Grid>
</Grid>
The problem here is the container ClickHandler just overrides all the clickhandlers that the filter screen has. So that tactic was not successful.
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on checkboxes are still processed.
<Grid onClick={ClickHandler} container direction="row">
<Grid item onClick={(e) => e.stopPropagation()}>
// Filter Screen that has buttons, checkboxes
</Grid>
<Grid item>
............
</Grid>
</Grid>
I have an idea that I think will work, but I'm not sure is the best approach or follows best practices. I would make use of the data- attributes on your components. Add an attribute like data-element="container" to your parent container. If event.target.dataset.element === "container" in your click handler, then you've clicked the background around the elements, otherwise you've clicked one of the elements. If necessary, you can also add data-element="componentN" to each of your components inside the container and move your logic for the onClick effects for your individual components inside there.
In my Windows Store App, when I press the arrow buttons on the keyboard to go to the next or previous item in my FlipView, a dashed line border appears around the FlipView to indicate that it has focus. This looks ugly and serves no purpose in my app. It looks like this border is hidden in other apps that I have looked at.
The SelectionBorderVisibility property is not available in WinRT. I was able to hide the border by defining a custom FlipView style and setting the Stroke property inside one of the rectangle to null as follows.
<Rectangle x:Name="FocusVisualWhite" IsHitTestVisible="False" Opacity="0" StrokeDashOffset="1" StrokeEndLineCap="Square" Stroke="{x:Null}" StrokeDashArray="1,1"/>
However, I'd rather not have to define an entire custom FlipView style if possible. Is there any other way to do this?
I have 2 questions about Winphone 8 UI Control:
How to make textbox non-editable with a color not gray-color?
If I have scrollview, there are many textbox inside, when I set foreground for one of this, I want to scrolllview auto scroll to this position(that item is out of view) to visible this item? (like listview)
Thank you.
To make the textbox non-editable give the IsReadOnly property as true.
XAML:
<TextBox
IsReadOnly="True"
>
The user may not modify the contents of this TextBox.
</TextBox>
In my WP8 app I want to add an image to listpicker Backgrond.
How can I add it?
<toolkit:ListPicker ExpansionMode="FullScreenOnly" Header="blabla:" Name="mylistpicker" Margin="0,395,222,47">
</toolkit:ListPicker>
<toolkit:ListPickerPage>
<toolkit:ListPickerPage.Background>
<ImageBrush ImageSource="=/images/bg3.png"/>
</toolkit:ListPickerPage.Background>
</toolkit:ListPickerPage>
It did not work for me.
any other code please?
If you want an Image in Background of ListPicker, You can add ListPicker within a Grid and set Grid Background property to your desired Image.
<Grid Background="/path/a.jpg">
//add ListPicker Here
</Grid>
I'm trying to create an "overlap" effect (for lack of a better term). There will be a splitter that when moved, exposes a different view of two similar images (e.g. between colored and grayscale).
I plan on using CustomGridSplitter from WinRTXAMLToolkit (due to WinRT's lack of a splitter). I'm thinking of starting with a grid similar to:
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="10" />
<RowDefinition />
</Grid.RowDefinitions>
<controls:CustomGridSplitter Grid.Row="1" Opacity="0.25"/>
</Grid>
... but I'm not sure how to proceed. If I specify two image controls on the first and third row (or column), how do prevent the image controls from moving (or so)? Also, is it possible to do this diagonally?
You could use two Rectangles that use an ImageBrush or two Image controls that use a Clip property to clip their contents. Unfortunately you can't have diagonal clips in WinRT, only rectangular ones. Maybe you could check if combining multiple RotateTransforms with a Clip would work, you never know. Other than above I would use a Slider instead of a GridSplitter for your scenario.