Hi i am developing WPF application using MVVM and i am try to add image as a button (like windows 8 start page button) Is there a way to have a Button only display as an image? I have an image that i would like to use as a button alone, but I can't seem to get the Button borders to go away and the Button background color to become transparent. or any way to use image as a Button ? Help me
<Button Style="{StaticResource RoundCorner}" Grid.Column="4" Grid.Row="2"
x:Name="New" Cursor="Hand" FontWeight="ExtraBold"
Margin="10,22,102,5" Grid.RowSpan="4" Grid.ColumnSpan="2">
<Image Source="pack://siteoforigin:,,,/Resources/NewIcon.png"
RenderOptions.BitmapScalingMode="HighQuality" Width="145" Height="93" />
</Button>
You can just replace the default Button ControlTemplate with a plain Image control. Try this:
<Button Click="Button_Click" Width="16" Height="16">
<Button.Template>
<ControlTemplate>
<Image Stretch="None"
Source="pack://application:,,,/AppName;component/FolderName/ImageName.png" />
</ControlTemplate>
</Button.Template>
</Button>
Related
I have been endeavoring to implement a JavaFX application using FXML which includes a toolbar in the bottom region of a BorderPane populated with four buttons displaying graphics only.
However, the buttons are displayed in gray outline only with no graphic content.
A simplified snippet of the FXML file is as follows:
<bottom>
<ToolBar fx:id="tbTextColor" >
<Button fx:id="btnRed" contentDisplay="GRAPHIC_ONLY">
<graphic>
<ImageView>
<image>
<Image url="#red.png"> </Image>
</image>
</ImageView>
</graphic>
</Button>
<!--more buttons-->
</ToolBar>
</bottom>
If anybody can inform me how to achieve the desired result, it will be much appreciated.
Thanks.
When I try to create a DatePicker it appears all white, and only the selected date is black which I changed through the Textcolor property. The rest of the graphics appear fuchsia in my case. How can I change the rest?
This is a known bug in Forms with Dark Theme.
There was a workaround posted recently
This is a super-ugly hack, but it solved the problem for me. Based on what #stefanbogaard86 suggested, I tried using Visual="Material", but the problem I ran into was that the DatePicker entry box didn't match the rest of the form. But, he's right that using Material did fix the issue with the picker rendering. So, I found this to get the best of both visuals:
<AbsoluteLayout>
<DatePicker
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
Date="{Binding Birthdate}"
Format="yyyy-MM-dd"
Style="{DynamicResource DatePicker}" />
<DatePicker
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
Date="{Binding Birthdate}"
Format="yyyy-MM-dd"
Opacity="0"
Style="{DynamicResource DatePicker}"
Visual="Material" />
</AbsoluteLayout>
The first picker is what we want to show in the form. The second one is what we want to be clickable and show the full date picker, but we don't it shown in the form, so its opacity is zero. They're both bound to the same property, so when you change the value they both work.
Like I said, this is super-ugly, but it works.
I want a button's text color to be the same on both iOS and Android. So I thought I'd just set the TextColor property in code to the color I wanted. On iOS, the disabled text color is still grey (which is what I want), however, on Android, the disabled text color is the same as the enabled text color. How do I make the disabled text color on Android grey (or whatever its default is for a disabled button)?
Thanks
That is the default behavior in Xamarin.Forms. To work around that and achieve a custom color, you can:
use triggers to change the color when going from enabled to disabled and vice versa
manually set the color when enabling and disabling the button
use a custom renderer
Because triggers are the most straightforward and consistent way of achieving what you want, I'll only cover that. You can see the xamarin docs for more information about custom renderers.
Using triggers, you can dynamically change the font color to gray when it is not enabled. See the docs for more information about triggers.
<Button Text="I am a Button">
<Button.Triggers>
<Trigger TargetType="Button"
Property="IsEnabled" Value="true">
<Setter Property="TextColor" Value="Red" />
<!-- red is the desired color when the button is enabled.-->
</Trigger>
<Trigger TargetType="Button"
Property="IsEnabled" Value="false">
<Setter Property="TextColor" Value="Gray" />
<!-- gray is the desired color when the button is disabled.-->
</Trigger>
</Button.Triggers>
</Button>
If above does not work for you, you could try to check this workaround. It uses a custom renderer and NSAttributedString for setting the title in disabled state
I'm trying to use the filter:grayscale(1) technique to grayscale an image. It works fine on the web but when I try it on my XUL image it's failing. It's turning it into a blurry square.
This is the before:
This is the after:
And here's a picture of the DOM inspection, my element is anonymous element.
Any ideas? That would be awesome! Thanks!
Edit:
I cant get code to replicate this outside for my addon but this is the code:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
<box class="profilist-tbb" >
<image class="toolbarbutton-icon" style="list-style-image: url(chrome://browser/skin/places/query.png)"/>
<image class="profilist-badge" style="filter:grayscale(1);transform:translate(-7px,14px) scale(.8);" src="chrome://branding/content/icon16.png"/>
<box flex="1">
<stack class="profilist-display-stack" flex="1">
<html:input class="profilist-input" style="display:none" />
<label class="toolbarbutton-text" crop="right" flex="1" value="rawr"/>
</stack>
</box>
</box>
</window>
I also worked around it by putting the grayscale on the box element above it which makes everything inside grayscale, not just this badge icon, but I'll have to live with it till I can replicate it :(
I've made this sample:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window width="400" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<textbox id="textBox1"/>
<textbox id="textBox2" style="-moz-user-focus: ignore;"/>
<textbox id="textBox3"/>
</window>
And, at least here, the style applied to the second textbox is doing nothing. I expected it to avoid the user focus, as the doc says.
Does someone experienced this?
--edit
To whom it may concern, the working version:
<window width="400" height="300"
onload="document.getElementById('textBox2').tabIndex='-1';"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<textbox id="textBox1"/>
<textbox id="textBox2" onmousedown="return false;"/>
<textbox id="textBox3"/>
</window>
The textbox itself never takes focus. Instead, XBL creates an anonymous XHTML input element inside the textbox, and this is what takes focus. You can stop the textbox taking keyboard focus by setting its tab index to -1, and mouse focus by preventing the default action of mousedown events.
Another approach is to set the textbox to disabled or readonly, depending on why you don't want the textbox to be focused.
I opened a bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=627691