I want to create a button using fontawesome library in xamarin
(expected output)
(this is mine)
<Button Text=" Bireysel"
TextColor="Black"
VerticalOptions="Start"
HorizontalOptions="Start"
FontSize="30"
Margin="15,0,0,0"
FontFamily="{StaticResource FontAwesomeSolid}"
BackgroundColor="Transparent"/>
I wanna change text style how can i do that?
Button can have both text and image with FontImageSource:
<Button Text="Left">
<Button.ImageSource>
<FontImageSource Glyph=""
FontFamily="{StaticResource FontAwesomeSolid}" />
</Button.ImageSource>
</Button>
Try this TextTransform="None"
<Button Text=" Bireysel"
TextColor="Black"
VerticalOptions="Start"
HorizontalOptions="Start"
FontSize="30"
Margin="15,0,0,0"
FontFamily="{StaticResource FontAwesomeSolid}"
BackgroundColor="Transparent"
TextTransform="None"/>
Related
Hello guys i'm making xamarin.forms app and have two inputs from entries and I need to add the numbers entered into a separate sums every time a button is pressed
x:Name="Player1"
Text="{Binding Player1.Text}"
Style="{StaticResource LabelStyle}"
FontSize="20"
HorizontalOptions="Center"
VerticalTextAlignment="Center"
LineBreakMode="WordWrap"
/>
<Entry Grid.Column="1" Grid.Row="0"
x:Name="scoreEntry1"
Keyboard="Numeric"
FontSize="25"
Placeholder="0"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Margin="0,20,0,0"
/>
<Label Grid.Column="0" Grid.Row="1"
x:Name="Player2"
Text="{Binding Player2.Text}"
Style="{StaticResource LabelStyle}"
FontSize="20"
HorizontalOptions="Center"
VerticalTextAlignment="Center"
LineBreakMode="WordWrap"
/>
<Entry Grid.Column="1" Grid.Row="1"
x:Name="scoreEntry2"
Keyboard="Numeric"
FontSize="25"
Placeholder="0"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Margin="0,20,0,0"
/>
<Grid>
<Button Grid.Column="0" Grid.Row="0"
Text="Next round"
BackgroundColor="#26940F"
TextColor="#FFFFFF"
Clicked="Next_round"
Command="{Binding ButtonNext}">
</Button>
I've tried to do the calculation in the .cs but couldn't figure it out. Can someone help me?
first, don't use an event and a command on the button - pick one or the other
to add the numbers, do something like this
public void Next_round(object sender, EventArgs args)
{
// use int.Parse if the number are ints, I'm assuming double
var val1 = double.Parse(scoreEntry1.Text);
var val2 = double.Parse(scoreEntry2.Text);
// add them
var sum = val1 + val2;
// you haven't specified what you want to do with the result???
}
note that this is a very basic approach, and very brittle - it will break if the user enters in a string that is not a valid double. To handle this you should add some exception handling (ie, a try/catch block), or use TryParse instead of just Parse. Refer to the C# docs on either of these topics
Please could someone assist me in trying to figure this out.
I have created a menu on a WPF page called DashView.xaml
this menu has buttons on it going down and I would like to know how to get the BottomDrawerContent to be visible once I click on a button.
Below I have given the code that is in DashView.xaml
<materialDesign:DialogHost x:Name="hostSales" >
<materialDesign:DrawerHost x:Name="SalesDrawerHost" Content="Sales" Foreground="GhostWhite"
FontWeight="Bold" FontSize="22" BottomDrawerCloseOnClickAway="True"
Cursor="Hand" Width="200" Height="30" ToggleButton.Checked="chkSalesBt1">
<materialDesign:DrawerHost.BottomDrawerContent x:Uid="dashSalesBt1">
<StackPanel x:Name="stkSalesBt1">
<Button Content="Record Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
<Button Content="Recent Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
</StackPanel>
</materialDesign:DrawerHost.BottomDrawerContent>
</materialDesign:DrawerHost>
</materialDesign:DialogHost>
I do have a class called DashClass.cs
Just not sure what I am meant to put in it or how I am meant to get the execution to show the BottomDrawerContent
Yout need a tooglebutton:
<ToggleButton
x:Name="menuToggler"
Style="{DynamicResource MaterialDesignHamburgerToggleButton}" />`
and in the DrawerHost use IsLeftDrawerOpen
<materialDesign:DrawerHost
x:Name="SalesDrawerHost"
Content="Sales"
Foreground="GhostWhite"
FontWeight="Bold"
FontSize="22"
BottomDrawerCloseOnClickAway="True"
Cursor="Hand"
Width="200"
Height="30"
IsBottomDrawerOpen="{Binding ElementName=menuToggler, Path=IsChecked}">
<materialDesign:DrawerHost.BottomDrawerContent x:Uid="dashSalesBt1">
<StackPanel x:Name="stkSalesBt1">
<Button Content="Record Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
<Button Content="Recent Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
</StackPanel>
</materialDesign:DrawerHost.BottomDrawerContent>
</materialDesign:DrawerHost>
My project is in Xamarin Forms and i have a very simple code.
<SwipeView x:Name="MainSwipe" BackgroundColor="#dcdde1">
<SwipeView.LeftItems>
<SwipeItems Mode="Reveal">
<SwipeItemView>
<StackLayout BackgroundColor="#208b55" Orientation="Vertical" Margin="20">
<Label Text="HITÉLET" Style="{x:StaticResource LabelLeftMenu}" x:Name="open_hitelet" Padding="10"/>
<Label Text="KULTÚRA" Style="{x:StaticResource LabelLeftMenu}" x:Name="open_kultura" Padding="10"/>
<Label Text="KÖZÉLET" Style="{x:StaticResource LabelLeftMenu}" x:Name="open_kozelet" Padding="10"/>
<Label Text="ÉLETMÓD" Style="{x:StaticResource LabelLeftMenu}" x:Name="open_eletmod" Padding="10"/>
<Label Text="GAZDASÁG" Style="{x:StaticResource LabelLeftMenu}" x:Name="open_gazdasag" Padding="10"/>
<Label Text="SZÍNES" Style="{x:StaticResource LabelLeftMenu}" x:Name="open_szines" Padding="10"/>
<Label Text="RÓLUNK" Style="{x:StaticResource LabelLeftMenu}" x:Name="open_rolunk" Padding="10"/>
</StackLayout>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
</SwipeView>
And i have a method to open left menu:
MainSwipe.Open(OpenSwipeItem.LeftItems);
But it isn't work perfectly.(does not open completely)
I have tested with shared coed, it's interesting. It shows the same with yours. Maybe it's an issue of SwipeView.
However, I have a workaround to solve this. You could add WidthRequest for the child view of SwipeItemView. As follows:(set WidthRequest="100")
<SwipeView x:Name="swipeView" HeightRequest="300">
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItemView>
<StackLayout BackgroundColor="#208b55"
Orientation="Vertical"
WidthRequest="100"
Margin="20">
...
</StackLayout>
</SwipeItemView>
</SwipeItems>
</SwipeView.LeftItems>
The effect:
In addition, you could submit it as an issue here in Github to follow it up there to know whether it has been sloved.
I've got a button using a font icon from Material Design Icons. (Displaying this icon as well as several others is working fine so converter omitted for brevity). Here is the XAML for the button:
<Button Margin="10"
Padding="0"
BackgroundColor="{StaticResource Background}"
CornerRadius="25"
FontFamily="{StaticResource MaterialFontFamily}"
FontSize="36"
HeightRequest="50"
HorizontalOptions="EndAndExpand"
Text="{Binding PlusIcon, Converter={StaticResource NameToIcon}}"
WidthRequest="50" />
As you can see I've got the padding set to 0, but it still displays like this:
Just to test I have done this with regular text too:
Looks fine if I set the font size smaller, but this is not what I want:
How do I force removal of the padding? And why is the text not centered when I change the font size? Issue happens on IOS and Android.
You should use the ImageButton with a FontImageSource
First you declare you FontImageSource in your styles:
<FontImageSource x:Key="IconBikeSmall"
FontFamily="{StaticResource FontAwesome}"
Glyph="{x:Static styles:IconFont.Biking}"
Size="{StaticResource SizeSmallIcon}"
Color="{StaticResource SecondaryColor}" />
Then you simply use it as value for the Source property of your button:
<ImageButton Source="{StaticResource IconBikeSmall}"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
Or even use it directly like this:
<ImageButton HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" >
<ImageButton.Source>
<FontImageSource
FontFamily="{StaticResource FontAwesome}"
Glyph="{x:Static styles:IconFont.Biking}"
Size="{StaticResource SizeSmallIcon}"
Color="{StaticResource SecondaryColor}" />
</ImageButton.Source>
</ImageButton>
I have a window with 3 textboxes and labels with following properties:
<Label x:Name="label" Content="_Label" Target="{Binding ElementName=textBox}"/>
<Label x:Name="label1" Content="Label"/>
<Label x:Name="label2" Content="_Label" Target="{Binding ElementName=textBox2}"/>
See this image
You can see that "label" and "label2" have the same ALT + L key but different Target property. When I focus textBox middle and I press ALT + L I need that textBox2 is focues (like in MFC). I can't use code behide because I was made about 200 windows.
Thanks a lot!
I think if you really need with out code behind or ViewModel you can do it by adding the same short cut to Label1 like below,
<Label x:Name="label" Grid.Row="0" Content="_Label" Target="{Binding ElementName=textBox}"/>
<Label x:Name="label1" Grid.Row="1" Content="_Label" Target="{Binding ElementName=textBox1}"/>
<Label x:Name="label2" Grid.Row="2" Content="_Label" Target="{Binding ElementName=textBox2}"/>
<TextBox x:Name="textBox" Grid.Column="1" Grid.Row="0"/>
<TextBox x:Name="textBox1" Grid.Column="1" Grid.Row="1"/>
<TextBox x:Name="textBox2" Grid.Column="1" Grid.Row="2"/>
If you can make a ViewModel then InputBinding with KeyBinding can make it work.