Why does .css border-radius not work with Xamarin xaml - css

I have numerous buttons defined in my xaml.
<ContentPage.Resources>
<x:StyleSheetExtension Source="Default.css" />
</ContentPage.Resources>
...
<Button x:Name="btnSale" BackgroundColor="#0000AA" Text="Sale" Grid.Row="0" Grid.Column="0" StyleClass="HeaderButtons" />
<Button x:Name="btnReturnExchange" Clicked="BtnReturnExchange_OnClicked" BackgroundColor="#0000AA" Text="Return/Exchng" Grid.Row="0" Grid.Column="1" StyleClass="HeaderButtons" />
<Button x:Name="btnOrder" Clicked="btnOrder_Clicked" BackgroundColor="#0000AA" Text="Order" Grid.Row="0" Grid.Column="2" StyleClass="HeaderButtons" />
<Button x:Name="btnARPayment" BackgroundColor="#0000AA" Text="A/R Payment" Grid.Row="0" Grid.Column="3" Clicked="BtnARPayment_OnClicked" StyleClass="HeaderButtons" />
<Button x:Name="btnCustActivity" BackgroundColor="#0000AA" Text="Cust. Activity" Grid.Row="0" Grid.Column="4" StyleClass="HeaderButtons" />
<Button x:Name="btnAdministrator" Clicked="BtnAdministrator_OnClicked" BackgroundColor="#AAAAAA" Text="Administrator" Grid.Row="0" Grid.Column="5" StyleClass="HeaderButtons" />
<Button x:Name="btnRoutines" BackgroundColor="#AAAAAA" Text="Routines" Grid.Row="0" Grid.Column="6" StyleClass="HeaderButtons" />
I also have a Default.css file:
button {
border-radius: 5;
}
.HeaderButtons {
border-width: 2;
font-size: 16;
font-style: bold;
border-color: black;
color: white;
}
No matter where I put the border-radius: 5;It will not round the corners like CornerRadius="5" which goes in the xaml file. I can leave it here or move it into the .HeaderButtons section, it makes no difference as far as I can tell. Any help would be greatly appreciated. Thanks in Advance.

Related

how to remove border-right/Left of material-ui Textfield?

how can i remove to "border-left" of the first textfield and 'border-right' of the last textfield
<ButtonGroup variant="outlined" aria-label="outlined button group">
<TextField label="text" color="secondary" focused />
<TextField label="text" color="secondary" focused />
<TextField label="text" color="secondary" focused />
</ButtonGroup>
Use InputProps to apply class to TextField.
<ButtonGroup variant="outlined" aria-label="outlined button group">
<TextField
label="text"
color="secondary"
focused
InputProps={{
classes: {
notchedOutline: "left"
}
}}
/>
<TextField label="text" color="secondary" focused />
<TextField
label="text"
color="secondary"
focused
InputProps={{
classes: {
notchedOutline: "right"
}
}}
/>
</ButtonGroup>
Create CSS file and then import in your component.
CSS:
.left {
border-left: none !important;
}
.right {
border-right: none !important;
}

Make StackLayout transparent so the WebView behind can be seen

I am using Visual Studio 2017, the project is a cross-platform Xamarin Forms mobile app, version 4.0
I would like to add a transparent StackLayout (Footer) that contains a non transparent button on top of a StackLayout that contains a webview.
I am trying to achieve this:
As you can see the bottom StackLayout (Footer) has an opacity of 0.9 and the WebView behind can still be seen.
I have tried this way:
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="WebView" TargetType="{x:Type WebView}">
<Setter Property="VerticalOptions" Value="Fill"></Setter>
<Setter Property="HeightRequest" Value="1000"></Setter>
<Setter Property="WidthRequest" Value="1000"></Setter>
</Style>
<Style x:Key="Footer" TargetType="{x:Type StackLayout}">
<Setter Property="BackgroundColor" Value="{x:StaticResource BlackColor}"/>
<Setter Property="VerticalOptions" Value="End"/>
<Setter Property="Orientation" Value="Horizontal"/>
<Setter Property="Opacity" Value="0.9"></Setter>
</Style>
<Style x:Key="AcceptButton" TargetType="{x:Type Button}">
<Setter Property="BackgroundColor" Value="{x:StaticResource YellowColor}"/>
<Setter Property="TextColor" Value="{x:StaticResource BlackColor}"/>
<Setter Property="WidthRequest" Value="125" />
<Setter Property="BorderRadius" Value="15" />
<Setter Property="VerticalOptions" Value="CenterAndExpand" />
<Setter Property="HorizontalOptions" Value="CenterAndExpand" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout>
<StackLayout VerticalOptions="CenterAndExpand">
<WebView Style="{StaticResource WebView}" Source="{Binding Url}"></WebView>
</StackLayout>
<StackLayout Style="{StaticResource Footer}">
<Button Text="{x:Static resources:AppLocalization.Term_Accept}" Style="{StaticResource AcceptButton}"></Button>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
But the Footer is all black and the WebView behind cannot be seen.
You guys have any ideas on how to handle this?
Thank you very much!
You want to overlay items, so it would be better to use a Grid
<ContentPage.Content>
<Grid>
<StackLayout VerticalOptions="CenterAndExpand">
<WebView Style="{StaticResource WebView}" Source="{Binding Url}"></WebView>
</StackLayout>
<StackLayout VerticalOptions="End" Style="{StaticResource Footer}">
<Button Text="{x:Static resources:AppLocalization.Term_Accept}" Style="{StaticResource AcceptButton}"></Button>
</StackLayout>
</Grid>
</ContentPage.Content>

Display long text inside Circular Button Completely

Am trying to create a Circular Button with Long Text inside it using Xamarin Forms. however on UWP platform if the text is longer than say 6 chars its Not visible completely.
How can i make the text fit to Width and Height inside the button.
Below is the Problem depicted .
in 3rd Button the Figure 100000 is cut at extreme right.
After increasing font size below is the Rendered UI.
The above has increased the font size however the text is cut off at corners.
FYI : Am using below Styles only on UWP to render button, is there any thing am doing wrong here? or how can i remove radius of textblock using this style?
<Style x:Name="MyControl" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="Border"
Background="White"
CornerRadius="50"
Width="110"
Padding="0"
Margin="0"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter x:Name="ContentPresenter"
Content="{TemplateBinding Content}"
ContentTransitions="{TemplateBinding ContentTransitions}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
IsTextScaleFactorEnabled="False"
TextWrapping="Wrap">
</ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
How can i make the text fit to Width and Height inside the button.
Xamarin button has FontSize property. You could set suitable double value for displaying all text.
<Button HeightRequest="60" WidthRequest="60"
BorderRadius="30"
VerticalOptions="Center"
BorderColor="Green"
BorderWidth="5"
HorizontalOptions="Center"
Text="100000"
BackgroundColor="Transparent"
FontSize="10"/>
It looks correct in my side.
If you want avoid click animation, Please copy the following FormsButton style that is removed PointerOver and Pressed storyboard to UWP Application Resource directly.
xmlns:forms="using:Xamarin.Forms.Platform.UWP"
<Style TargetType="forms:FormsButton">
<Setter Property="Background" Value="{ThemeResource ButtonBackground}" />
<Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />
<Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="FocusVisualMargin" Value="-3" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="forms:FormsButton">
<ContentPresenter
x:Name="ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
>
</ContentPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

How to apply css selector in ZK

Here are some part of my codings inside index.zul :
<grid>
<columns>
<column/>
<column/>
</columns>
<rows>
<row>
<label value="${labels.personal.name}"/>
<label value="#load(vm.personal.name)"/>
</row>
<row>
<label value="${labels.personal.id}"/>
<label value="#load(vm.personal.id)"/>
</row>
<rows>
<grid>
I tried to use the CSS below but somehow it bold every label inside row element.
.z-label:FIRST-CHILD{
font-weight: bold;
}
So, how can I apply font-weight only to the first label tag for each row element ?
You can use the sclass attribute so your css is applied with the default css.
<style>
.bold{
font-weight: bold;
}
</style>
<grid>
<columns>
<column/>
<column/>
</columns>
<rows>
<row>
<label value="${labels.personal.name}" sclass="bold"/>
<label value="#load(vm.personal.name)"/>
</row>
<row>
<label value="${labels.personal.id}" sclass="bold"/>
<label value="#load(vm.personal.id)"/>
</row>
</rows>
</grid>
You can test it in this fiddle.
Update:
I looked around in the DOM and played a little further with the css selectors so I came to this solution
.z-row-inner:first-child .z-label {
font-weight:bold;
}

there are some images in my windowsphone8 app which i want to be displayed when someone clicks on thumbnail of that image

Ihave Used Buttons To show thumbnails of image
<phone:PanoramaItem Header="gallery" Orientation="Horizontal" Foreground="#FFD8D36D" Height="611">
<!--Double wide Panorama with large image placeholders-->
<ScrollViewer Margin="0,4,16,37" >
<StackPanel Orientation="Vertical" Height="878" Width="404" RenderTransformOrigin="0.491,0.995">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<Button Height="120" Width="120" Margin="12,0,0,0" Click="Button_Click_3">
<Button.Background>
<ImageBrush Stretch="UniformToFill" ImageSource="/gallery/1.png"/>
</Button.Background>
</Button>
<Button Height="120" Width="120" Margin="12,0,0,0">
<Button.Background>
<ImageBrush Stretch="UniformToFill" ImageSource="/gallery/2.png"/>
</Button.Background>
</Button>
</StackPanel>

Resources