When I create a simply WPF application that has a number in the title "4More" for example the text will stay as "4More" when run on an English version of Windows. When I run it on an Arabic version of Windows it stays as "4More". However when I change the flow direction to RTL and run on Arabic it starts doing number substitution changing the European 4 to the Arabic 4 (٤). I would like to be able to control the number substitution for the title of the window.
I have applied the NumberSubstitution.Substitution="European" onto the window but it did not make a difference.
Here is my XAML code as it stands:
<Window x:Class="TestTitle.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestTitle"
mc:Ignorable="d"
Title="4More"
Height="350"
Width="525"
FlowDirection="RightToLeft"
NumberSubstitution.Substitution="European">
<Grid>
</Grid>
</Window>
What do I need to do to get it show the European number 4 in the title?
Related
I have a ComboBox in a UWP project that I want to modify. I want to change the background color of the StackPanel(?) containing the ComboBoxItems, but I haven't found a simple way of doing this.
Here, I want to change the color of the light gray padding.
The color surrounding the ComboBoxItems should match, but instead it is the default gray that stands out.
Here's an example where MSN Money's ComboBox has a custom padding color to match the ComboBoxItems. This is what I am hoping to achieve.
I use the word "padding", but it is really just the color of the element containing the ComboBoxItems.
As I understand it, I have to modify the provided generics.xaml file in the Windows 10 SDK, but that will modify all of the ComboBoxes I'm using. I could create a custom control that inherits from ComboBox, but wouldn't that require me to write a new control whenever I wanted to change this color? There has to be an easier way to change this.
#Bart This is the code I found in the template for the Popup in the ComboBox. I am not sure where "SystemControlBackgroundChromeMediumLowBrush" came from in your explanation.
<Popup x:Name="Popup">
<Border x:Name="PopupBorder"
Background="{ThemeResource ComboBoxDropDownBackground}"
BorderBrush="{ThemeResource ComboBoxDropDownBorderBrush}"
BorderThickness="{ThemeResource ComboBoxDropdownBorderThickness}"
You should NEVER touch the generics.xaml file in the SDK folder, that's a "system file". That's like changing some file deep in your Windows installation to change an icon explorer (and might result in other applications to change this as well).
There are multiple solutions:
Edit the control's template in your own app (with Visual Studio, Blend or by simply copying the default template. If you let it unnamed (name a template by setting x:Key) it will be applied to all your ComboBoxes. If you only want some changed, you should give it a key and use it as StaticResource.
The piece of code you are looking for is the Popup control in the template.
<Popup x:Name="Popup">
<Border
x:Name="PopupBorder"
Background="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}"
BorderBrush="{ThemeResource SystemControlForegroundChromeHighBrush}"
BorderThickness="{ThemeResource ComboBoxDropdownBorderThickness}"
Margin="0,-1,0,-1"
HorizontalAlignment="Stretch">
Override the ThemeResource to give it another color. Note that this will have an effect on other controls in your app using the same ThemeResource. But this is still a lot better than changing the generics.xaml and less work than redefining the template.
This is done by redefining the resource key.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="SystemControlBackgroundChromeMediumLowBrush" Color="DarkGray" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
How can I force Visual Studio 2013 to indent following code?
<Grid>
<TextBlock Margin="42"
Text="yolo"
FontSize="42">
</TextBlock>
</Grid>
Unfortunatelly
CONTROL+K CONTROL+D
and
CONTROL+K CONTROL+F
don't work...
I know that I can rewrite it to
<Grid>
<TextBlock>
<TextBlock.Margin>42</TextBlock.Margin>
<TextBlock.FontSize>42</TextBlock.FontSize>
yolo
</TextBlock>
</Grid>
but i don't want to do this this way.
Update
I can't install Xaml Styler according to #Mashton's answer, because I've got following error.
The only way I know would be to use an extension, such as Xaml Styler, which will break a Xaml onto new lines for each attribute. Other plugins exist, I'm sure, which will give you more control.
Suppose I have this XAML in a WinRT app:
<Button Content="" AutomationProperties.Name="Add A New Thing" Style="{StaticResource AppBarButtonStyle}" />
Because the value of AutomationProperties.Name is so long, the text on the button spans two lines. I would like it to stay on a single line. I tried expanding the width of the button to something that would definitely be wide enough for the text, but the text seemed to want to continue to be on two lines. What is the markup I should add to this Button control to keep the text on a single line?
Thanks,
Mike
So, this stumped me. Here's what I tried:
<StackPanel>
<!-- Standard -->
<AppBarButton Label="The quick brown fox jumps over the lazy dog"></AppBarButton>
<!-- -->
<AppBarButton Label="The quick brown fox jumps over the lazy dog"></AppBarButton>
<!-- Underscore -->
<AppBarButton Label="The_quick_brown_fox_jumps_over_the_lazy_dog"></AppBarButton>
</StackPanel>
Each attempt resulted in the exact same result, text wrapping.
This leaves you with two options.
Stop using such long strings
Update the template
So, since you will want to be using an AppBarButton instead of a standard Button with an AppBar style, I'll cater my answer to Windows 8.1 and Visual Studio 2013. I don't have 2012 anyway.
The template (just right click the control in the designer and select Edit Template / Copy. You will find this line, near the bottom:
<TextBlock x:Name="TextLabel"
Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"
FontSize="12" FontFamily="{TemplateBinding FontFamily}" TextAlignment="Center"
TextWrapping="Wrap" Text="{TemplateBinding Label}" Width="88"/>
You can see it is set to wrap. Just change TextWrapping="Wrap" to TextWrapping="NoWrap" and you'll get what you want. Then just make sure all your buttons use the template you have edited (so you might want to relocate it up to app.xaml).
It's that easy, really.
PS: you might be tempted to use a WPF trick of TextBlock.TextWrapping="NoWrap" on the primary control. This does not work, so I can save you time trying.
Best of luck!
I'm new to SL and must be missing something really fundamental here.
I have created a very simple user control like so:-
<UserControl x:Class="Company.UI.Common.Controls.TestControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="Yellow" Width="100" Height="20">
<TextBlock Text="foo"></TextBlock>
</Grid>
</UserControl>
Then in my view I'm referencing it as follows:-
xmlns:medControls="clr-namespace:Company.UI.Common.Controls;assembly=Company.UI.Common"
Then including it in the UI like this:-
<medControls:TestControl Width="100" Height="20" Visibility="Visible" />
However nothing appears when I run the app, just an empty space 100x20 pixels where the control should be. I've used Silverlight Spy and it shows the control being present, with all the correct details - type, assembly, visibility, etc.
I have put a breakpoint in the user control's constructor, and can confirm that InitializeComponent() is being called.
Any suggestions as to what is happening would be greatly appreciated, as I'm tearing my hair out over what should be a very simple thing to do!
Thanks in advance
Andy
This turned out to be a known bug in VS2010, reported here: http://connect.microsoft.com/VisualStudio/feedback/details/683175/visual-studio-failing-to-embed-g-resources-file-in-dll-with-certain-silverlight-project-files
Basically, in some situations, the order of elements in the .csproj file can change, resulting in the XAML files not being included in the assembly, and this is what was happening with me. No runtime errors. Nothing. Just an empty space where the user control should have rendered.
The above link tells you what you need to do to resolve the problem, and involves manually editing the .csproj file and moving certain elements around.
Incidentally, this same bug was also the cause of another problem I'd been having where my user control's code-behind was referencing a control (e.g. "this.txtForename"). The control reference, which is set up in InitializeComponent using FindName(), was always null.
Hope this helps someone else.
Andrew
See if this helps:
http://msdn.microsoft.com/en-us/library/system.windows.controls.usercontrol%28v=vs.95%29.aspx
http://10rem.net/blog/2010/02/05/creating-customized-usercontrols-deriving-from-contentcontrol-in-wpf-4
I never tried to create a custom usercontrol in xaml i always did it programatically, has you can see in this examples, but you can pull it off if you use one ContentControl or one ContentPresenter and then call you UserControl
How to create ← (←) in XAML? I want to create backspace button.
If directly entering ← does not work, try
←
I am certain there must be a better way than this, but you can just use the special character directly in the xaml.
I was able to cut and paste a back arrow into the content of a text block and it displayed correctly.
<TextBlock Height="23" Width=20 HorizontalAlignment="Left" Name="textBlock1" Text="" VerticalAlignment="Top" >
←
</TextBlock>
So you should be able to use that text block as part of the template for a control.
I'm not sure exactly what you need, but I think it would give a better effect to use an image for the back arrow instead of using text.
The encoding of the files are UTF-8 so you can just write in the arrow right in the file.
e.g.,
<Label>←</Label>
<Label Content="←" />