I'm creating a WPF C# .Net App with the Aero theme which is supposed to run on Win7 as well as Win10.
On Win10 everything works as it's supposed to, however on Win7 the GUI looks vastly different.
In particular, my MenuItems simply seem to ignore certain settings such as VerticalContentAlignmentand BorderThickness.
Pics:
Win7 vs
Win10
How do I fix this?
(Some Code:)
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
<MenuItem Header="Intranet"
Grid.Column="2"
x:Name="Menu_Intranet"
ToolTip="Intranet"
BorderBrush="white"
BorderThickness="5"
VerticalAlignment="Stretch"
Click="Menu_1_Click"
ToolTipService.ShowOnDisabled="true"
VerticalContentAlignment="Center"/>
Thanks in advance!
I edited the MenuItemControlTemplate (right click on the control you want to edit in the designer -> edit template) and applied it to the MenuItems via Template="{DynamicResource MyMenuItemControlTemplate}".
I guess this leaves no room for the OS/Theme to apply its own settings.
Related
I have a radio button in a WPF Application which works normally in Windows 7.
However in some XP machines, the radio button selection is not visible but the clicked event is fired.
Why does this happen? Is this a repaint issue or a computer settings issue?
UPDATE
This problem comes only in the computer which uses Windows Classic Theme
The solution was to add a label inside the radiobutton as below:
<RadioButton
IsChecked="{Binding Path=IsSelected}"
GroupName="InstallType"
Margin="2,3.5"
Foreground="Black"
>
<Label Content="{Binding Path=DisplayName}"/>
</RadioButton>
I saw the solution here:
http://www.carlos-roque.com/2011/07/25/making-wpf-checkbox-and-radiobutton-display-correctly-in-windows-classic-theme/
You can check with the template used by radio button. Make sure the brushes/colors used in windows 7 are available in XP.
These links should provide some more help
http://msdn.microsoft.com/en-us/library/ms751600.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/jj709925.aspx
Check for the "Checked State"
You should check the version of the .NET framework. on these XP machines
In Windows 8 RTM with VS2012 RTM I noticed my WPF app was giving me deformed radio buttons so I decided to create a sample to see if I was doing something wrong.
Here's the entire XAML App :
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" SizeToContent="WidthAndHeight">
<Grid>
<StackPanel Margin="20">
<RadioButton Content="Option 1" GroupName="1"/>
<RadioButton Content="Option 2" GroupName="2"/>
<RadioButton Content="Option 3" GroupName="3"/>
</StackPanel>
</Grid>
</Window>
Here I have the DPI settings set to 100%, which is actually NOT the default in Windows 8 (well at least for my 1920x1200 screen it isn't). You'll see the radio buttons are perfect.
This is the same exact application with DPI settings at 125% which is the default DPI for my screen resolution.
Here's 150%
You can see the inner circles aren't centered within the outer circle and it looks TERRIBLE. System applications with radio buttons are fine - but my WPF 4.5 app is not. Once again this sample app is 100% RTM bits and from scratch under Win 8.
Is it just all broken or is there a way to fix this (apart from insisting people put 100% DPI scaling).
Was really hoping Win8 would have gone a long way for high res screens and scaling issues like this, but something simple is badly broken out of the box :-(
Edit: filed connect bug https://connect.microsoft.com/VisualStudio/feedback/details/758368/radio-button-rendering-is-incorrect-on-windows-8-with-125-dpi-scaling-set
Edit: 8/29/12:
The WPF team has recently reviewed this issue and will not be
addressing this issue as at this time the team is focusing on the bugs
impacting the highest number of WPF developers. If you believe that
this was resolved in error, please reactivate this bug with any
necessary supporting details.
Everything in WPF is styled. In the case of the default system styles they sometimes, in my own experience, have little issues like this. A simple fix, to confirm it is the style and not the OS itself is to restyle the control yourself and see if that fixes it.
You can find the original style by looking at this question. These will help you rebuild and / or fix the issue
You could try put the stackpanel in a viewbox .. maybe
Here's the situation:
I have a combobox within a button,, In expression blend when I add image to combo box item with the cod below, there's no problem apparently, image and textblock are showing well but as I run the proj.((F5)) there'e no sign of image, What I'm doing Wrong???
here's the code I use to add the image:
<ComboBoxItem Background="LightCoral" Foreground="Red"
FontFamily="Verdana" FontSize="12" FontWeight="Bold">
<CheckBox Name="CoffieCheckBox">
<StackPanel Orientation="Horizontal">
<Image Source="coffie.jpg" Height="30"></Image>
<TextBlock Text="Coffie"></TextBlock>
</StackPanel>
</CheckBox>
Any help Is much appreciated...
One likely problem might be that the image file is in your project folder without being copied to the build folder; /bin/Release for example. The application then will not find the file anymore. You can either ensure that the image is being copied when the application is compiled (that alone may not work actually as unqualified URIs make the parser look for resources as far as i know, the designer however does not seem to care) or you can embed the image as a resource. I do not know how to change compile settings in Blend however as i only use Visual Studio...
I had a similar problem showing images (used Uri strings) in a listview in a Silverlight application. They appeared properly in Expression Blend, but were not visible when I started it from Visual studio.
I kept my images in a folder called Images in my project, by setting the "Build action" for my image properties into "Content" fixed the problem. Now they show up when running the application. Hope it helps!
I'm using Blend 4 and VisualStudio 2010 to build a kiosk WPF 4.0 app that has a wizard-like function. I've decided I'd like individual steps moved to separate UserControls, to keep the main window of the application as lean as possible. However, I'm having trouble including the UserControl into the main window, since image paths are being mangled after moving the XAML to a separate UserControl file.
This code works when it's put into the main window XAML:
<Button Grid.Row="1" Grid.Column="2" Height="{Binding ActualWidth, RelativeSource={RelativeSource Self}}" Margin="20" VerticalAlignment="Bottom" Style="{DynamicResource ImageButton}">
<Button.Background>
<ImageBrush ImageSource="/Images/Extra/motor_boat_2.jpg" Stretch="UniformToFill"/>
</Button.Background>
</Button>
But when I move that code to a separate user control and include it in the main window, the designer throws and exception:
IOException: Cannot locate resource 'images/extra/sailing_boat.jpg'.
I've tried using a couple of different syntaxes, but all fail, sometimes using the %ProgramFiles% directory, other times converting the absolute path to relative (as above). Sometimes, the Build Project operation in Blend 4 fails because of this.
All the images are marked as Resource with Build Action set to Copy Always.
VisualStudio has no problem building and running the application, the UserControl displays correctly within the running application with no thrown exceptions.
EDIT:
Using relative paths in the UserControl and then building and running the app from VisualStudio and switching back to Blend correctly displays the images, until the next modification to the UserControl.
Use Pack URI like following:
Uri uri = new Uri("pack://application:,,,/Images/Extra/motor_boat_2.jpg");
I cannot figure out how to bring a TabItem to the front of a TabControl in a visual studio 2008 wpf project so that I can see the controls I'm editing.
The visual display part only ever shows the controls on the first TabItem. It does works in run time, just not in design time.
Sounds retarded, maybe I am, but I can't figure out how and I'd really appreciate if anyone could tell me how?
I've tried bringing things to the front, pushing things to the back? Clicking through document outline, looking through properties, double clicking, pulling my hair out, banging my head on the wall....
How can something so simple elude me? :(
Thank you.
Setting the IsSelected property on the TabItem works but it's obscure to say the least and kludgy at best.
This problem has in fact been fixed to work the way you would expect it to work since 8/11/2008 however Windows Update doesn't notify you that the update is available, not even if you check from the Visual Studio 2008 "Help>Check for Updates" menu item. I just ran across this issue myself as I was migrating to a new laptop where the Tab Control worked properly on my old machine but not on my new machine. On closer inspection I found that the difference was that the Visual Studio 2008 SP1 was missing, once I installed that the Tab Control started working properly again. Go to;
http://msdn.microsoft.com/en-us/vstudio/cc533448.aspx
This makes me wonder though, even before the update to VS2008 the Tab Control worked properly in Expression Blend and since the SP1 update was to VS2008, not to the .Net framework, the control shouldn't have changed. So, did Microsoft write the design time behavior for the Tab Control into the UI vs the control itself? That would be very wierd but how would it work in Blend and not VS2008 if the design time behavior was in the control? Maybe Blend and VS2008 each have their own set of control templates that handle design time behavior? You would think that the two programs would share them if they did. Hmmmm...
PS: Don't forget to install the 3 security updates to VS2008 SP1 that Windows Update finds now, 500MB holy cr_p batman.
Use the IsSelected property on the TabItem
<TabControl>
<TabItem Header="Tab1">
<TextBlock Text="This text is not visible"/>
</TabItem>
<TabItem Header="Tab2" IsSelected="True">
<TextBlock Text="This text is visible" />
</TabItem>
</TabControl>