How to change ShowMessageAsync flow direction to "Right to Left"? - wpf

Is there any way to change Mahapps messagebox window (ShowMessageAsync)'s flow direction to Right to left ?

You can set the FlowDirection for the whole MetroWindow and all childrens.
FlowDirection="RightToLeft"
If you only want to set this to MessageDialog then you can change the style e.g. in your App.xaml like this
<Style TargetType="{x:Type Dialog:MessageDialog}"
BasedOn="{StaticResource {x:Type Dialog:BaseMetroDialog}}">
<Setter Property="FlowDirection" Value="RightToLeft" />
</Style>
So all message dialogs will get this style.
Hope this helps!

Overwriting the style should do it,
see: How to change MahApps.Metro dialog content template width?
The answer has a nice little tutorial.

Related

WPF button text scrolling on mouse over

is it possible for buttons that have longer Content(text) than the max button width to kinda scroll the remaining text from right to left on mouse over? something like an electronic banner is the best I could explain it.
as of now this is the only thing that reflects my button style xaml.
<Page.Resources>
<Style x:Key="Str" TargetType="{x:Type Button}">
<Setter Property="Width" Value="90"/>
</Style>
</Page.Resources>
Yes. That's usually called marquee.
You can template a wpf control to do just about anything.
Put a canvas in there and a textblock. Animate the canvas.Left of the textblock.
There's a marquee implementation here:
https://social.technet.microsoft.com/wiki/contents/articles/31416.wpf-mvvm-friendly-user-notification.aspx?Redirected=true#Marquee
You would, obviously, want to start the animation using a datatrigger and ismouseover true.

MahApps Dialog overriding Button style?

I'm using the MahApps metro toolkit, and have the following inside my Apps.xaml file:
<Application.Resources>
<ResourceDictionary>
...
<Style TargetType="{x:Type Button}" />
...
</ResourceDictionary>
</Application.Resources>
Which nicely overrides the MahApps metro style for Button back to 'default'.
However, I've written a custom dialog (called DialogEditGroup - which derives from CustomDialog), but weirdly the <Button /> style has reverted back to using some form of styling from the MahApps metro toolkit.
The only way I've been able to reset it again, is by adding the following lower down in my Apps.xaml ResourceDictionary:
<Style TargetType="{x:Type controls:DialogEditGroup}">
<Style.Resources>
<Style TargetType="{x:Type Button}" />
</Style.Resources>
</Style>
I really don't want to have to add this in for every custom dialog I write, and I'm sure the above 'fix' isn't the correct way of solving the problem. Can anyone suggest a proper way of addressing this issue?
`
(Top of image is 'mahapps', bottom is 'default / generic')

Xaml Grid Styling

New to WPF, I'm having some trouble creating a styles in my code, I was able to make some buttons styles by drawing rectangles and making them into buttons, this opened a template editor so I was able to do it.
Now I'm wanting to create a template for a repeating stackpanel/grid layout, and I wrote it by hand this time, but I am getting an error that says the "template is not a valid member"
This is the kind of thing I was trying to create, but the Property="Template" bit is underlined in red. Can somebody explain to me the reason behind this? How do I create or initialize the template?
<Style x:Key="LaneStyle" TargetType="{x:Type Grid}">
<Setter Property="Width" Value="760"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Grid}">
<!-- Things here -->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
If someone could direct me to a tutorial on styles/templates that would be nice as well, haven't been able to find one that explained it in more detail.
Grid is not a control, therefore you cannot apply a ControlTemplate to it. If you're looking for a "repeater" kind of thing, you should be using an ItemsControl.
The best way to create templates/styles is by using Microsoft Blend 3.0/4.0
Over there one can easily find out what's the progress after doing each change.
In your case, a grid cannot be styled as it is a container not a control. If you wish to customize some control need to modify the control template of the control.

Changing glow speed in default WPF Button

The default WPF button we have in Visual Studio: when mouse hover on it, the button background will glow from grey to blue. The speed is too slow. How to speed up the glowing effect in XAML?
Is there something like below?:
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="GlowSpeed" Value="0.01" />
</Style>
Of course, this property doesn't exist. What property is that suppose to be? Is that some sort of Animation?
This animation is embedded in the default Template of the button, you would need to change the default template which can be found on MSDN (Default WPF Themes link).

Can you set the content of a button in wpf with a style?

When I try this, all the buttons turn blue, but the content isn't set.
<Window.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Blue"/>
<Setter Property="Content" Value="Edit"/>
</Style>
</Window.Resources>
Any ideas?
EDIT : This example was indeed somewhat too oversimplified. My problem was in changing styles in runtime, where the color was changing allright, but not the content. The solution for me was not to initialize content in xaml, but in code.
Remember if you set the content property in Style, but if you give some other content in inline xaml it will not work for example if you use
Sometimes XAML Editor like Blend will put Content="" if you just try to delete the content, it will not remove attribute, you will have to check.
So even if your XAML contains Content="" or your code initializes Content Property to even null or empty string, it will not work.
Works for me (tried it in kaxaml). But black text on a Blue background can be hard to read. You sure its not there?

Resources