I have a Metro application with a ListView that has this definition:
<ListView Grid.Row="0" x:Name="lvData" CanDragItems="True" CanReorderItems="True" SelectionMode="Extended">
<ListView.ItemTemplate>
<DataTemplate>
<Border Padding="4,0,0,0">
<Grid Width="{Binding ElementName=lvData, Path=ActualWidth}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="65"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Stretch"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="2" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="3" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="4" HorizontalAlignment="Right"/>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="65"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Stretch" TextTrimming="WordEllipsis"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Right"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Once this ListView is filled, how do I Scroll this ListView with a mouse? Can't seem to work it out. Any help would be appreciated.
I had a control on the page that was constantly stealing focus through other events that were being triggered, as such this event was NOT being fired. Things are working well now.
Specifically, it was the WebView control. See this article for workaround:
[WinRT Trick] Scrolling
Related
<g id="Closed_Eyes">
<path d="Closed eye data" />
</g>
<g id="Open_Eyes">
<animate dur="0" attributeName="opacity" from="1" to="0" repeatCount="indefinite" />
<path d="Open eye data" />
</g>
I have an SVG face and like to animate blinking eyes. The animate does not work because the duration is zero, but if I change zero to some time, it is animate opacity. I should not be using opacity but I must use hiding on the open_Eyes object. The idea is that if we hide open_Eyes, the background close_Eyes shows and then shows. This will give if eyes are blinking. Kindly guide me on how we can animate blinking with animate.
I tried with opacity, but it changes the opacity with time. That is wrong. Perhaps I need two animations. First, hide the open_Eyes object and then show it.
Using dur="0" in animate won't work. If you just want to toggle the object you could either use a really small duration value (wouldn't recommend it though) or use the set tag like this:
<animate dur="0.001s" attributeName="opacity" from="1" to="0" repeatCount="indefinite" />
or this
<set attributeName="visibility" to="hidden" fill="freeze" />
You also dont need the repeatCount if you just want it to stay invisible or when using no duration. Use fill="freeze" instead, as seen in the second code example i made, to keep the state after the animation finished.
I'm trying to create a svg button with transparent text. It looks like there is no way to do it easily in React-native, so maybe I'll just create an svg, that will have transparent text. How do I do that?
I've tried to do it in Figma, but it looks like the only way to do it there is to put a specific image behind. Text can't be truly transparent, it can only mask a picture.
You can use an svg mask with a white rectangle and a black text. The shapes you have - like the rectangle with rounded corners in this example - will be painted only under the white parts of the mask. Since the text is black it will apear like a hole.
svg{border:solid; background:silver;}
<svg>
<mask id="m">
<rect x="10" y="10" width="280" height="130" fill="white" />
<text x="150" y="75" font-size="90" font-family="arial" dominant-baseline="middle" text-anchor="middle" fill="black">text</text>
</mask>
<rect x="10" y="10" width="280" height="130" rx="20" mask="url(#m)" />
</svg>
I am trying to figure out a nice layout for a group of controls with labels. If i have a label on the left of a textbox for example, the base line of the label and the textbox are not on the same vertical position. An often workaround ist to just vertically center both controls but that doesn't look nice if you have multi line textbox controls.
I got a few combinations.
I hoped a relative panel would provide the option to align the baseline like it does with the android relative layout panel. Unfortunately it doesn't.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<RelativePanel>
<TextBlock Text="Name:" Name="t1"></TextBlock>
<TextBox Text="Content" RelativePanel.RightOf="t1" ></TextBox>
</RelativePanel>
</Grid>
A grid does not help as well.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{x:Bind Label}" Style="{ThemeResource BaseTextBlockStyle}"/>
<TextBox Grid.Column="1" Text="Content" HorizontalAlignment="Stretch"></TextBox>
</Grid>
</Grid>
Obviously a horizontal stackpanel has no magic as well.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Horizontal">
<TextBlock Grid.Column="0" Text="{x:Bind Label}" Style="{ThemeResource BaseTextBlockStyle}"/>
<TextBox Grid.Column="1" Text="Content" VerticalAlignment="Top"></TextBox>
</StackPanel>
</Grid>
A vertical stackpanel would avoid the problem, but i'd prefer the label on the left of the control.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical">
<TextBlock Grid.Column="0" Text="{x:Bind Label}" Style="{ThemeResource BaseTextBlockStyle}"/>
<TextBox Grid.Column="1" Text="Content" ></TextBox>
</StackPanel>
</Grid>
Do you have any ideas how to align baselines which is / or maybe a nice layout idea for a lot of input controls and labels?
I had a quick look through the docs and I don't think there is any equivalent to Android's baseline alignment in UWP. Text controls don't expose the position of their baseline for panels to make use of, as it is highly dependent on the template of the control (which can be completely changed, unlike in Android where the visual appearance of views are sort of hard-coded).
Anyway, by inspecting the visual tree of a textbox, I found that the innermost TextBoxView (the control which actually displays and handles text input for the TextBox control) renders text in the same way that a TextBlock does (meaning the padding and such is the same). So as long as we can align the top edges of the TextBlock to the TextBoxView, then the text for both controls will be at the same vertical position. Of course, the font and font size for both controls needs to be the same (which it is by default).
The TextBoxView is pushed down by its parent ScrollContentPresenter by 3px (effective pixels), and the text box border by 2px. So you just need to add 5px of top margin to the TextBlock and the text for both controls will align.
FYI this is based on the default TextBox template provided by SDK version 14393 which I am using. Microsoft can change these styles with new SDK versions.
Looking at the Android docs, the View class has a method getBaseline; in UWP, UIElement (or FrameworkElement) has no such equivalent. Searching the visual tree and trying to determine the baseline of the first text element you see mightn't work in every case (some elements have more than one text element).
If you're going to have lots of these left-labelled-elements, some suggestions:
Create a UserControl with the label and textbox in the correct position. That way you only have the margin hardcoded in one place in your code and if you need to change it you only need to change one piece of code.
The TextBox control (like many others) has a Header property where you can specify text which will be displayed immediately above the textbox. You can change the template so that the header will be to the left of the textbox instead.
It seems that the recommended way is to use the Header property and have the label on top. Most UWP apps do this (in Groove when you edit song info, Edge's settings pane, etc). This is probably because when displayed on a mobile device, there isn't much horizontal space.
The easiest way to achieve what you want is to not create a TextBlock and a TextBox, but simply two TextBox elements with any of the layouts you have suggested at the top. Then apply the following Style to the TextBox element which should only show the label to make it look like a TextBlock:
<Style x:Key="TransparentTextBoxStyle" TargetType="TextBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="IsTapEnabled" Value="False" />
<Setter Property="IsTabStop" Value="False" />
</Style>
I think setting IsReadOnly, IsTapEnabled and IsTabStop should be enough to disable all potential interactions (just made a quick test), but to be sure you could also simply set IsEnabled to false and modify the template to look the same like if it would be enabled (you can get the default template in VS2015 by opening the Document Outline window (if you don't have it visible, you can find it in View > Other windows) open the visual tree to get to your item, then right-click, Edit Template and Edit a Copy...).
Test in Simulator mode, the GridView wont scroll vertically even I have 100 records to show, it show a vertical bar but can not be used to scroll. What I need to do to make it scrolling vertically or horzontally?
Your help is appreciated for this problem. Thanks
<GridView x:Name="CustomersGridView"
Grid.Row="1"
Margin="37,174,73,89"
Foreground="White"
SelectionMode="Single"
IsSwipeEnabled="True"
IsItemClickEnabled="True"
ItemsSource="{Binding Mode=OneWay, Source={StaticResource CustomersViewSource}}"
ItemTemplate="{StaticResource CustomerTemplate}"
ItemClick="CustomersGridView_ItemClick"
// Horizontal or vertical here:
ScrollViewer.HorizontalScrollBarVisibility="Auto"
SelectionChanged="CustomersGridView_SelectionChanged">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
Wrap the control in a ScrollViewer
For example:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="ScrollViewer Sample">
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
<TextBlock TextWrapping="Wrap" Margin="0,0,0,20">Scrolling is enabled when it is necessary.
Resize the window, making it larger and smaller.</TextBlock>
<Rectangle Fill="Red" Width="500" Height="500"></Rectangle>
</StackPanel>
</ScrollViewer>
</Page>
We can create shapes like rectangle, circle etc. Can we create a rectangle inside another rectangle?
You can't create a rectangle inside an other rectangle. But you can make 2 rectangles to look so.
You use the <rect> tag for rectangles. By looking at the rectangle description in the specifications, you can see that the content model don't allow <rect> to contain an other <rect> (or shape).
An example of what you can do :
<rect x="0" y="0" width="200" height="100"/>
<rect x="25" y="25" width="150" height="50"/>
You can also add a <g> around those two rectangles to group them, like this :
<g>
<rect x="0" y="0" width="200" height="100"/>
<rect x="25" y="25" width="150" height="50"/>
</g>
More explanations here : http://www.w3.org/TR/SVG/struct.html#Groups
You also have the alternative of using a path to draw 2 rectangles with only one tag. It all depend of your needs.