How to set our our custom image as icon in mahapps drop down button - mahapps.metro

I am using the Mahapps drop down button. I am unable to set the image that is local to my application as icon of the drop down button. How to achieve that. Currently am Maintaining my image source like below
<BitmapImage
x:Key="LoginBottom"
UriSource="pack://application:,,,/oApplication;component/Resources/LoginBottom.png" />
after that am refering that image like below
<Controls:DropDownButton
Icon="{StaticResource LoginBottom}"
>
But instead of the image am getting the urisource as text. which means whatever text is mentioned in the urisource is being shown in the drop down button.

You need to use an Image Control with your BitmapImage Resource.
Like so:
<Controls:DropDownButton>
<Controls:DropDownButton.Icon>
<Image Source="{StaticResource LoginBottom}" />
</Controls:DropDownButton.Icon>
</Controls:DropDownButton>

Related

Tooltip on Button

I am trying to set tooltip on button as shown in the code below based on image choice. I want to set tooltip based on Image if button displays normal image I would like to set tool tip as "Active" and if displays mouse hover image then tool tip should be "Non-Active". I can set tool tip on main button without any problems. Images displays fine,however I am not able to toggle/display tooltip based on normal or hover image.
NormalHoverImageButton
is standard button that contains two DependencyProperties that hold the normal image and the hover image as ImageSource. Is there any way in the xaml, I can set this tooltip property.
<c:NormalHoverImageButton DockPanel.Dock="Left"
ToolTip="Display Tool Tip"
NormalImage="{Binding Status, Converter={StaticResource NormalImageSourceConverter}}"
HoverImage="{StaticResource MouseHoverImage}"
Visibility="{Binding IsTestTrue, Converter={StaticResource MyVisibilityConverter}}">
</c:NormalHoverImageButton>
Try
ToolTip="{Binding RelativeSource={RelativeSource Self}, Path = NormalImage, Convertert={...}"
Converter is supposed to check whether NormalImage is null. If so return one kind of text tooltip otherwise another. Let me know if it works.

how to show image along with conent on a button in wpf using mvvm [duplicate]

This question already has answers here:
Button template with image and text in wpf
(7 answers)
Closed 8 years ago.
I am creating one sample WPF-MVVM application , in that I have one image which indicates '+' sign and I have a button with content 'Edit'. Now I have to show the image along with Name 'Edit' on a button. Please let me know the solution for this problem.
EDIT
here I am able to show the image but the name is appered below the image. But I want to show the name beside the image.
you can do something like this
<Button Margin="104,78,84,60" Name="button1" Height="100" Width="200">
<StackPanel Orientation="Horizontal">
<Image Source="ssv.png" Stretch="None" Height="50" Width="50" />
<TextBlock TextAlignment="Center">Text value for this.</TextBlock>
</StackPanel>
</Button>
There are a few ways you could create an 'image button', one way would be to create a custom which derives from Button and adds an Image property, or a user control that uses a Button and declaratively adds the image as part of the buttons's control template in the user control XAML.
However, these approaches mean that the layout of the image within the button is fixed, so it isn't particularly flexible.
A nicer option is to create an attached property which stores the image location, and then reference this attached property value in the buttons control template. You can then create a style for the control template to make the layout reusable across buttons.

How do I display a bitmap image in my Wpf window using only XAML?

I have a blank window and i want a image in the center.I first tried dragging and dropping in the designer.Doesn't work.Then i tried an assortment of other examples on the internet.Couldn't get it to work either.one kinda worked but it wouldn't let me change the image's position.
Put an Image control in a Grid:
<Grid>
<Image Source=... Stretch="None" />
</Grid>

image control - dynamic load image from the resource file

I create in the code some image control and i want to set on this image control some of the picture that i saved ( load those pictures before creating the image control )
How can i do it ?
Specify your image in your Resource like this
<BitmapImage x:Key="SampleImageSource" UriSource="sample.png" />
and assign that to your image control like
<Image Source="{StaticResource SampleImageSource}" />
or if you are trying to do in code
img.Source = (ImageSource) Resources["SampleImageSource"];

Make a silverlight textblock act like a hyperlink

I'm pretty new to silverlight. I have a text block that is displayed inside a datagrid
(inside a DataGridTemplateColumn.CellTemplate template to be precise).
I'd like to dynamically make some of the textblocks into hyperlinks that open a new window.
Is there a way to do this - so far all I can come up with is using a hyperlink button and trying to style it to look like a text block.
Any help would be very much appreciated.
HyperlinkButton is a ContentControl so it can actually take some kind of pre-styled TextBlock (or other control) as it's content (instead of just using a simple string as Content).
<HyperlinkButton NavigateUri="http://myurl.com">
<TextBlock Text="My Link Text" Foreground="Black" />
</HyperlinkButton>
You would have to use a custom HyperlinkButton template if you wanted to style it to get rid of the default teal colored focus ring, etc. You could also set the IsEnabled property of the HyperlinkButton to false to prevent link behavior on any cells that weren't actually links if you are trying to set them up in some dynamic way.

Resources