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>
Related
So I have a Button where I want to add an image, but the app is crashing when the view gets loaded (view doesn't even show up, using Xamarin Live Player). If I create an extra image field the image shows up.
Here is the code:
<Image Grid.Row="3" Source="trash.png"></Image>
<Button Grid.Row="4" Image="trash.png" ></Button>
Any ideas why?
I am trying to create a user interface where a user can drag an image around the screen atop a background image. Currently the DraggableImage is being moved around with some sliders that change DraggableBounds in the view model.
<AbsoluteLayout>
<Image Source="{Binding DraggableImage, Mode=TwoWay}" AbsoluteLayout.LayoutBounds="{Binding DraggableBounds}" />
<Image Source="{Binding FrameImage, Mode=TwoWay}" Aspect="AspectFit" WidthRequest="1300" HeightRequest="500"/>
</AbsoluteLayout>
I've tried using the Pan Gesture that's on Microsofts Xamarin docs with little success. I'm not trying to pan within an image but move a smaller image over a larger. Is there an existing pattern to solve this?
I have content page in my xaml file. I have a Stacklayout with orientation vertical in it. I want to put a dialog in middle of content page above this stacklayout. Please suggest some way. Thanks in advance!
An easy way to provide dialogs that feel native to the platform your on is through using the UserDialogs plugin.
If you want to create something of your own you would probably have to come up with something like this:
<Grid>
<StackLayout>
...
</StackLayout>
<Grid IsVisible="{Binding ShowMessage}">
<Label Text="Message" HorizontalOptions="Center" VerticalOptions="Center" />
</Grid>
</Grid>
The nested Grid will act as an overlay of sorts spanning your entire page.
My button looks like a text field instead of a button. Here's a screenshot:
Here's the code:
<Button FontWeight="Bold" Click="setWallpaper" Foreground="black" FontSize="35"
Margin="62,560,127,48" >Set Lockscreen</Button>
How do I fix it and make it look like a good old button?
Looks like the problem is that you have an image as your background and the button is transparent so it is showing the image. Just change your button background to White and it should fix it
<Button FontWeight="Bold" Click="setWallpaper" Foreground="Black" FontSize="35" Background="White" Margin="62,560,127,48" >Set Lockscreen</Button>
In my Windows Store App I use a button which has a star shape with some text. I use the following XAML code for the button:
<Button Name="goButton" BorderThickness="0" FontWeight="Bold" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,-91,33,0" FontSize="25" IsEnabled="True" Click="goButton_Click" >
<Grid Width="227" Height="222">
<Image Source="Assets/redstar.png" />
<StackPanel Orientation="Vertical" Margin="77">
<TextBlock TextAlignment="Center" Text="Tag"></TextBlock>
<TextBlock TextAlignment="Center" Text="ist um!"></TextBlock>
</StackPanel>
</Grid>
</Button>
This is what is the button looks like:
Unfortunately it often happens that clicks in the area of the star are not recognized, e.g. the event handler is not startet. I suppose that it has something to do with the image, for it works fine if I remove the image from the grid. But this doesn't solve my problem.
Any suggestions?
Don't see anything wrong off the top. You could try a couple of things:
Instead of click, try the Tapped event for the button.
Try tapped on the container Grid.
Get rid of the Grid & put all button content in a StackPanel & then try tapped/clicked on it.
Go with patterns like MVVM & associate your button with a Command.
Hope these help!