I have a UX class called InputWithLabel that includes both a label and a TextInput.
I am trying to add an 'X' to it that can be used to clear the input text. My plan is to later add the functionality to only display this 'X' when there is actual text in the input field.
For now though, I can't figure out how to do this while not allowing the input to go over top of the 'X'. If you think it's a bug, I'll clean it up and report it as such but I suspect it's just something simple I don't understand so I thought I'd just ask you about it... I tried a number of ideas but none of them seemed to work for me...
<StackPanel ux:Class="InputWithLabel" Width="50%">
<string ux:Property="Label" />
<string ux:Property="Value"/>
<string ux:Property="IsPassword"/>
<Text Color="#28549b" FontSize="12" Margin="0,12,0,0" Value="{ReadProperty Label}"/>
<Rectangle CornerRadius="2" StrokeWidth="1" StrokeColor="#bdbebf">
<TextInput FontSize="16" Value="{Property Value}" IsPassword="{ReadProperty IsPassword}"/>
<Panel ux:Name="ClearButton" Alignment="Right">
<Rectangle SnapToPixels="True" Height="1px" Width="10px" Color="#bdbebf">
<Rotation Degrees="45"/>
</Rectangle>
<Rectangle SnapToPixels="True" Height="1px" Width="10px" Color="#bdbebf">
<Rotation Degrees="-45"/>
</Rectangle>
</Panel>
</Rectangle>
</StackPanel>
There is no bug, it's all about understanding how layout works in Fuse. When you put a TextInput along with a Panel in a Rectangle, they both occupy the same space. There is no implicit space consumption happening (by design). The result of that is, as you can see, that things go over one another.
To achieve what you need, it would be a far better strategy to go with a DockPanel, because inside of a DockPanel you can explicitly consume space by docking its children to its sides. Here's an example, based on the code you initially posted:
<StackPanel ux:Class="InputWithLabel" Width="50%" IsPassword="false">
<string ux:Property="Label" />
<string ux:Property="Value"/>
<string ux:Property="IsPassword"/>
<Text Color="#28549b" FontSize="12" Margin="0,12,0,0" Value="{ReadProperty Label}"/>
<DockPanel>
<Rectangle CornerRadius="2" StrokeWidth="1" StrokeColor="#bdbebf" Layer="Background" />
<TextInput FontSize="16" Value="{Property Value}" IsPassword="{ReadProperty IsPassword}" Margin="4">
<WhileContainsText Invert="true">
<Change clearButton.Visibility="Collapsed" />
</WhileContainsText>
</TextInput>
<Panel ux:Name="clearButton" Dock="Right">
<Rectangle SnapToPixels="True" Height="1px" Width="10pt" Color="#bdbebf">
<Rotation Degrees="45"/>
</Rectangle>
<Rectangle SnapToPixels="True" Height="1px" Width="10pt" Color="#bdbebf">
<Rotation Degrees="-45"/>
</Rectangle>
</Panel>
</DockPanel>
</StackPanel>
You'll notice I also included UX code for only showing the close button when there's some text in the input. Cheers!
You're welcome to visit Fuse docs to read more about Layout in general and Responsive layout in particular for useful details on the topic.
Related
I'm trying to fix the accessibility bugs I found in Accessibility insights for windows app for my desktop application.
Here is my code for datagrid-
<controls:DataGrid
x:Uid="DataTable"
x:Name="detailGrid"
Margin="0"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible"
AreRowDetailsFrozen="False"
AreRowGroupHeadersFrozen="True"
AutoGenerateColumns="False"
CanUserSortColumns="True"
CanUserReorderColumns="True"
CanUserResizeColumns="True"
ColumnHeaderHeight="28"
MaxColumnWidth="500"
FrozenColumnCount="0"
GridLinesVisibility="None"
HeadersVisibility="Column"
IsReadOnly="False"
RowDetailsVisibilityMode="Collapsed"
SelectionMode="Extended"
SelectionChanged="OnDataGridSelectionChanged"
RowHeight="25"
RowGroupHeaderPropertyNameAlternative="Range"
ItemsSource="{x:Bind ViewModel.GridData}" Visibility="{x:Bind ViewModel.IsContentVisible, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
<controls:DataGrid.Columns>
<controls:DataGridTemplateColumn Header="Name">
<controls:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Margin="10,0,0,0" Width="15" Source="../Assets/folder.png" Visibility="{Binding ChildFolder.IsFolder, Converter={StaticResource BoolToVisibilityConverter}}" />
<Image Margin="10,0,0,0" Width="15" Source="../Assets/file.png" Visibility="{Binding ChildFolder.IsFolder, Converter={StaticResource BoolToInverseVisibilityConverter}}" />
<HyperlinkButton Height="28" FontFamily="Segoe" Content="{Binding ChildFolder.FolderName}" Margin="0" FontSize="12px" Tapped="onSingleTapped" DoubleTapped="onDoubleTapped" IsDoubleTapEnabled="True" CommandParameter="{Binding ChildFolder}" HorizontalAlignment="Stretch">
</HyperlinkButton>
</StackPanel>
</DataTemplate>
</controls:DataGridTemplateColumn.CellTemplate>
</controls:DataGridTemplateColumn>
<!--<controls:DataGridTextColumn Binding="{Binding ChildFolder.BlobType}" Header="Blob Type" />-->
<controls:DataGridTextColumn Binding="{Binding ChildFolder.LastModifiedLocal}" Header="Last Modified" />
<controls:DataGridTextColumn Binding="{Binding ChildFolder.ContentTypeDisplay}" Header="Content Type" />
<controls:DataGridTextColumn Binding="{Binding ChildFolder.ContentSize}" Header="Size" />
<controls:DataGridTextColumn Binding="{Binding ChildFolder.LeaseStateString}" Header="Lease State" />
</controls:DataGrid.Columns>
</controls:DataGrid>
Can someone please let me know how I can fix the above bug as I'm working first time on windows accessibility?
These are the documentation that it asks to refer but I'm not sure how to fix it.
https://learn.microsoft.com/en-us/accessibility-tools-docs/items/uwpxaml/customcontrol_localizedcontroltype
https://learn.microsoft.com/en-us/accessibility-tools-docs/items/uwpxaml/customcontrol_name
Based on the screenshot you provide, this error is coming from the LocalizedControlTypeNotCustom rule. It's hard to tell for sure from just the screenshot and the XAML, but I would guess that UWP is creating a custom control based on your data template. If an AT user navigates to the group, then the control type will be read as "Custom", which provides no indication of how to interact with this element. If that's truly the case, then it might be possible to specify the element as a Group by setting the AutomationProperties.Name in the data template.
That's about all I can offer from the information that you've provided. If you can create a minimal repro app, then share it in a gist or a public repo, we can try to shed more light on specific ways to address this.
--Dave Tryon
Accessibility Insights team
I am trying to place a synfcusion button that has a calendar image near a xarmain forms entry box.
But its a bit out of alignment what I have tried so far is.
<Label Text="Please select a start date below"></Label>
<StackLayout Orientation="Horizontal">
<Entry x:Name="txtDateStartEntry" WidthRequest="200" ></Entry>
<syncfusion:SfButton x:Name="btnPickStartDate" CornerRadius="10" HorizontalTextAlignment="Start" ShowIcon="True" Clicked="btnPickStartDate_Clicked" FontSize="24" BorderThickness="2" TextColor="White" BackgroundColor="White" Text="..." >
<syncfusion:SfButton.Content>
<Grid ColumnDefinitions="Auto, *, Auto" ColumnSpacing="16" Padding="16">
<Image Grid.Column="1" HorizontalOptions="End" WidthRequest="30" HeightRequest="30" Source="cal16.png" VerticalOptions="End"/>
</Grid>
</syncfusion:SfButton.Content>
</syncfusion:SfButton>
</StackLayout>
What I have eneded up with is this.
As you can see its a bit far away from the entry field and doesnt look like it belongs.
If you're using Syncfusion, you should make use of SfTextInputLayout which provides leading/trailing view functionality for the express purpose of adding descriptive iconography to an input view.
Code example assumes importing the following xmlns:
xmlns:sftl="clr-namespace:Syncfusion.XForms.TextInputLayout;assembly=Syncfusion.Core.XForms"
<sftl:SfTextInputLayout TrailingViewPosition="Inside">
<Entry x:Name="txtDateStartEntry" WidthRequest="200" />
<sftl:SfTextInputLayout.TrailingView>
<Image HeightRequest="30" Source="cal16.png">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="btnPickStartDate_Clicked" />
</Image.GestureRecognizers>
</Image>
<sftl:SfTextInputLayout.TrailingView>
</sftl:SfTextInputLayout>
Note: when using LeadingView or TrailingView, it's recommended to not assign a Width value as Syncfusion will calculate the width based on the height you request to maintain aspect ratio of the specified view. Therefore I have intentionally excluded HeightRequest from the Image.
I'm developing the DMS windows UWP application In which I want to show a user information on DataGrid. For this I am using MyToolkit.Controls.DataGrid. I want to change the header size and give the border for header. I also want to change the list items font size. so any one have a full style for DataGrid. how to hide the DataGrid column ?
the header size and give the border for header.
The header is object type that mean you could custom it's content. If you want to add border you could refer the following code. But MyToolkit does not support modify the header size.
<controls:DataGridTextColumn
Width="200"
Binding="{Binding Lastname}"
IsAscendingDefault="False"
>
<controls:DataGridTextColumn.Header>
<Border BorderThickness="1" Padding="5,5,5,5" BorderBrush="Red" CornerRadius="5">
<TextBlock Foreground="Green" Text="Lastname" />
</Border>
</controls:DataGridTextColumn.Header>
</controls:DataGridTextColumn>
change the list items font size
If you just want to change the list items font size, you could edit DataGridTextColumn FontSize property.
<controls:DataGridTextColumn
Width="200"
Binding="{Binding Firstname}"
FontSize="25"
Header="Firstname"
/>
how to hide the DataGrid column ?
Just set with property as 0.
<controls:DataGridTextColumn
Width="0"
Binding="{Binding Firstname}"
FontSize="25"
Header="Firstname"
/>
<ScrollView id="scrollGeneric" height ='auto' visible='false'>
<View id="formView" height='auto'>
<View id='distSlider' top='0' height='100'>
<Label id="lblGeneric" >
Search Distance:
</Label>
<Slider id="sliderDistance" top="50" min="2" max="80" width="50%"/>
<Label id="sliderDistanceText" width='auto' top="50" right="40" />
<Label id="sliderDistanceTextMeasure" width='auto' top="50" right="10" text="km" />
</View>
</View>
</ScrollView>
I have set the height auto for scrollView and formView. However whenever I add more views inside of the formView the size of the window does not expand vertically with it. It will eventually crop out the views that exceed the window height.
The only way to solve this is to manually specify the height of each view within the form view div.
Is there anyway I can avoid doing this, thanks
Have you tried using Ti.UI.SIZE instead for the height? As per the documentation, "height:auto is not recommended for new development and will be deprecated in the future."
I have a WPF Menu and a Tab control. I would like the list of menu items to be generated from the collection of TabItems on my tab control. I am binding my tab control to a collection to generate the TabItems. I have a TabItem style that uses a ContentPresenter to display the TabItem text in a TextBlock. When I bind the tab items to my menu the menu items are blank. I am using a Style Setter to set the Menu Item name, but I am not sure what property of the TabItem I would use to set the MenuItem text. Is there a workaround for my scenario? Is it possible to bind to the Header property of the tab item, when I do not know the number of tabs in advance? Below is a copy of my xaml declarations. Tab Control and items:
<DataTemplate x:Key="ClosableTabItemTemplate">
<DockPanel HorizontalAlignment="Stretch">
<Button
Command="{Binding Path=CloseWorkSpaceCommand}"
Content="X"
Cursor="Hand"
DockPanel.Dock="Right"
Focusable="False"
FontFamily="Courier"
FontSize="9"
FontWeight="Bold"
Margin="10,1,0,0"
Padding="0"
VerticalContentAlignment="Bottom"
Width="16" Height="16"
Background="Red"
/>
<ContentPresenter HorizontalAlignment="Center"
Content="{Binding Path=DisplayName}">
<ContentPresenter.Resources>
<Style TargetType="{x:Type TextBlock}"/>
</ContentPresenter.Resources>
</ContentPresenter>
</DockPanel>
</DataTemplate>
<DataTemplate x:Key="WorkspacesTemplate">
<TabControl
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource ClosableTabItemTemplate}"
Margin="10"
Background="#4C4C4C"/>
</DataTemplate>
My Menu and partial style listing
//I am not sure which value am I suppose to use, since I am not using header
<Menu Background="Transparent">
<MenuItem Style="{StaticResource TabMenuButtonStyle}"
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type TabControl}}, Path=Items}"
ItemContainerStyle="{StaticResource TabMenuItem}">
</MenuItem>
</Menu>
Create the following style and bind Header property to display property in ViewModel
<Style TargetType="{x:Type TabItem}">
<Setter Property="Header" Value="{Binding PropertyInViewModel}" />
</Style>