I have this code
<Image Name="LightOn_BMP" Source="Res/LightOn.bmp" Canvas.Left="150" Canvas.Top="10" />
<Image Name="LightOff_BMP" Source="Res/LightOFF.bmp" Canvas.Left="150" Canvas.Top="10" />
<Button Canvas.Left="215" Canvas.Top="150" Click="PowerOn">
<Image Name="SwitchDown_BMP" Source="Res/SwitchDown.bmp" />
</Button>
<Button Canvas.Left="215" Canvas.Top="150" Click="PowerOff">
<Image Name="SwtichUp_BMP" Source="Res/SwitchUp.bmp" />
</Button>
And I want in pure XAML to make the PowerOn event to change so that LightOn.bmp is visible and LightOff.bmp is hidden and hide the Switchdown.bmp picture/button
Then I should be able to figure out how to make the event for the PowerOff
Simply put, you can't. The whole idea behind WPF is that you should separate behavior from display. So, at least without making some crazy black magic, you won't be able to change the state of the Image object (visible to false).
Related
I am develop na UWP app, and I would like to have a transparent button. I try this (Is a simple example of my button):
<Button Name="Button"
Opacity="0">
<Image Source="/Assets/image.png"/>
</Button>
I want a button with an image, in which only the button is transparent. I've tried it that way, and by putting: Opacity="0" it puts everything transparent, and I want it to just be transparent.
Method 1
Set Opacity="0" for Button.Background. You can do it by using below code.
<Button>
<Button.Background>
<SolidColorBrush Opacity="0"/>
</Button.Background>
</Button>
Method 2
Set #00000000 as the background color of the Button. Since UWP support ARGB(Alpha RGB) color you can directly set opacity for any color in UWP app.
<Button Background="#00000000"/>
Im new to NS and I have a project. I want a Button floating inside a ScrollView.
<ScrollView>
<StackLayout orientation="vertical">
<AbsoluteLayout >
<Button top="0" left="0" right="0" text="Test" style="font-size: 10; margin:5; " />
</AbsoluteLayout>
<Label text="Trending Now: " cssClass="trending-label" />
<Repeater items="{{ categories }}">
<Repeater.itemTemplate>
.
.
.
</Repeater.itemTemplate>
</Repeater>
</StackLayout>
</ScrollView>
But its not working. The Button is also scrolling. I want the Button to be floating on ScrollView. Thank you.
The reason why the button is scrolling together with the other items is that everything is situated in a ScrollView. In order to have only the Label and the Repeater scrolling, the Button should be placed outside of it.
Another thing I have noticed is that on the Button, simultaneously are applied left and right alignment, which might cause a problem.
I made a possible implementation of the float button, which you can check here.
I'm currently developing a Windows Phone application.
I have a view with a button in which I would like to set an image.
I found a lot of solution through Internet but it still not work.
Actually, it works when I put an URL from the Internet. The image is well displayed on the button but when it's from my resources folder, no image is loaded.
Here is my XAML code to do that :
<Button Grid.Row="1" Command="{Binding ShowSearchFilterCommand}" Height="100" Width="100">
<StackPanel>
<Image Source="resources/SearchFilterIcon.png" />
</StackPanel>
</Button>
I set the build action of my image to "Content". The designer display the image so I don't understand what I did wrong.
You have to set the correct path to your image source as in a way /FolderName/ImageName.png.
If the images are placed inside nested folders set like this
Source="/FirstFolderName/SecondFolderName/.../ImageName.Extnsion"
Try this:
<Button>
<ItemsControl>
<Image Source="/Assets/images/ImageName.png"></Image>
</ItemsControl>
</Button>
I am trying to implement a simple app in Alloy that has a very basic structure but I cannot get it to layout reliably. I am trying to bottom align a group of navigation buttons with a working area above them which in the following example would be a TableView.
<Alloy>
<Collection src="book">
<Window height="100%" id="main" title="My Library {opts.username}" exitOnClose="true" onOpen="loadExtras">
<TableView id="content" dataCollection="book" top="10px" bottom="100px" onDragEnd="refreshTable">
<TableViewRow title="{title}" color="black" onClick="showBook"/>
</TableView>
<View bottom="0px" height="72px" layout="horizontal" id="actionPanel">
<Button class="footerBtn" onClick="refreshTable">View</Button>
<Button class="footerBtn" onClick="refreshTable">Help</Button>
<Button class="footerBtn" onClick="refreshTable">List</Button>
<Button class="footerBtn add" onClick="addBook"></Button>
</View>
</Window>
The only way I can get this to work is to specify a height for the TableView such as height="80%" and then play with this value until things layout as I would prefer but I do not want to do as I need this to work independently of the devices physical screen size.
How can I implement this kind of layout in Alloy to get a view to pin to the bottom of the screen with a variable working area above it - or, do I have to assume a standard height and work relative to that?
Try pinning the table to the bottom of the parent view and then setting the height to be 80% of the parent view height. Also, use dp values to be screen independent.
<TableView id="content" height="80%" bottom="100dp"
onDragEnd="refreshTable"
dataCollection="book">
Below is code for my button, so what properties should I add to make button invisible but content must be visible.
<Button x:Name="PART_PreviousButton"
DockPanel.Dock="Left"
Content="<"
Focusable="False"
Opacity="0" />
You need to edit the button Template to have this kind of result.
This link explains it pretty well, the easiest way is to do it with blend: http://msdn.microsoft.com/en-us/library/bb613598.aspx