I used this tutorial to implement a multilingual WPF application. Everything compiles, runs and works. But there is a problem: whenever I try to refer to a DynamicResource:
<TextBlock Grid.Row="1" Grid.Column="0" Text="{DynamicResource subtimer}" />
Visual Studio (2015) shows me a warning: The resource could not be resolved. It does not prevent working but it is just annoying and distracting (50 warnings for my smallest app).
Related
I am trying to upgrade my application template up to V8+. Previously working xaml seems to be broken. .NET Framework 4.7.2, ReactiveUI 8.3.1
<!--Client Area-->
<reactiveUi:RoutedViewHost x:Name="ViewHost"
Margin="3,9.667,3.333,3"
HorizontalAlignment="stretch"
VerticalAlignment="Stretch"
Grid.Row="1">
<reactiveUi:RoutedViewHost.DefaultContent>
<WrapPanel>
</WrapPanel>
</reactiveUi:RoutedViewHost.DefaultContent>
</reactiveUi:RoutedViewHost>
Gives a design-time warning:
"Don't know how to detect when Reactiveui.RoutedViewHost is activated/deactivated, you may need to implement IActivationFoViewFetcher". Am I missing a package or has there been a fundamental change in RoutedViewHost behavior?
There is a new nuget package called reactiveui.wpf that you need to include.
This will register a IActivationForViewFetcher.
I moved from .Net Framework 3.0 to 4.0 and the Japanese (and English as well) text became clear and lost weight
I want it back as it was in .Net 3
photo: new = .Net 4, old = .Net 3
I've followed this blog trying to fix it but no success yet
tried the following with different combinations:
<TextBlock Text="{Binding Text}" FontSize="16" Foreground="White" FontFamily="MS Gothic" RenderOptions.ClearTypeHint="Enabled" />
<TextBlock Text="{Binding Text}" FontSize="16" Foreground="White" FontFamily="MS Gothic" TextOptions.TextFormattingMode="Ideal"/>
<TextBlock Text="{Binding Text}" FontSize="16" Foreground="White" FontFamily="MS Gothic" TextOptions.TextRenderingMode="ClearType"/>
Any suggestions how to solve this?
It is not a solution, but on Microsoft's forum, there was an answer that the thicker font display is "caused by internal font optimization of WPF rendering system" for two fonts, MS UI Gothic and Bold MS UI Gothic.
As there are no solutions suggested there, I assume that you can not avoid that optimization. If MS UI Gothic are not MUST for what you are making, you may use Meiryo or other Japanese fonts to work around it.
This is also not a solution but I had a similar issue in that I wanted to use a particular font which was not available on Windows XP, but was in Vista and Win 7. I found an open source compatible font and included it as a resource in my application. This way I ensured that the application font looked the same across all versions of Windows.
You may be able to find a font that you could include in your application.
We are developing a WPF application for .NET 4.
One day the client told me that the new release does not work (application just quits upon startup) on his Windows 7 machine and he found the exception log in the Windows Event Viewer:
Application: myapp.exe Framework Version: v4.0.30319 Description:
The process was terminated due to an unhandled exception. Exception Info: System.Windows.Markup.XamlParseException
Stack: at System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
at ... (I guess no point to continue...)
This problem is driving me crazy because nor me nor another developer cannot reproduce it on our machines, and we cannot reproduce it even on a clean Windows 7 install in VirtualBox.
When we tried to find the changes which broke the application for the client, we found the offending piece. Here is the difference:
This works fine:
<ComboBox x:Name="comboBoxZoom" Margin="130,10,0,0" HorizontalAlignment="Left" Width="40" FontFamily="Arial" FontSize="12" VerticalAlignment="Top" TabIndex="1" Panel.ZIndex="2" />
This breaks:
<ComboBox x:Name="comboBoxZoom" Style="{StaticResource comboBoxStyle}" Margin="130,10,0,0" HorizontalAlignment="Left" Width="40" FontFamily="Arial" FontSize="12" VerticalAlignment="Top" TabIndex="1" Panel.ZIndex="2" />
Essentially the difference is only
Style="{StaticResource comboBoxStyle}"
but ths style has been used in other parts of our application before without any issues! And the same file which causes this exception, contains many other Style="{StaticResource someotherstyle}" and they work fine on the client machine.
All these styles are located in one file ControlStyles.xaml. The comboBoxStyle is a modified style copied from some website, similar to this one:
http://social.msdn.microsoft.com/Forums/nl/wpf/thread/53134b87-1a99-4998-a1fb-b3d8a9bd2773
Why does Style="{StaticResource comboBoxStyle}" make my app crash only on some certain machines and how to fix this bug?
I had the same problem and after pulling my hair out for two days, I figured the solution using Windbg with the help of someone in the C# IRC channel.
So in my case, the exception was thrown because I hadn't set the type attribute for app.config's trace listeners, and it had nothing to do with XAML, although oddly enough when I removed the combobox binding in my XAML, I could run the program in release mode, but the real solution lied in the app.config. I could run the program fine in debug mode though. This sounds like a nasty bug with the compiler.
So look for possible oversights in your app.config, if everything seems right there, then just grab Windbg and debug it on your own until you find the root cause of the exception.
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");