Use StringFormat to add a string to a WPF XAML binding
Your first example is effectively what you need: <TextBlock Text=”{Binding CelsiusTemp, StringFormat={}{0}°C}” />
Your first example is effectively what you need: <TextBlock Text=”{Binding CelsiusTemp, StringFormat={}{0}°C}” />
When you are writing your wpf code and VS tell that “The name ABCDE does not exist in the namespace clr-namespace:ABC”. But you can totally build your project successfully, there is only a small inconvenience because you can not see the UI designing (or just want to clean the code). Try to do these: In … Read more
I would simply associate the handler in the View constructor: MyWindow() { // Set up ViewModel, assign to DataContext etc. Closing += viewModel.OnWindowClosing; } Then add the handler to the ViewModel: using System.ComponentModel; public void OnWindowClosing(object sender, CancelEventArgs e) { // Handle closing logic, set e.Cancel as needed } In this case, you gain exactly … Read more
There’s no NotifyIcon for WPF. A colleague of mine used this freely available library to good effect: http://www.hardcodet.net/wpf-notifyicon (blog post) https://github.com/hardcodet/wpf-notifyicon (source code) https://www.nuget.org/packages/Hardcodet.NotifyIcon.Wpf/ (NuGet package) http://visualstudiogallery.msdn.microsoft.com/aacbc77c-4ef6-456f-80b7-1f157c2909f7/
You can put the textboxes inside a grid to do percentage values on the rows or columns of the grid and let the textboxes auto-fill to their parent cells (as they will by default). Example: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=”2*” /> <ColumnDefinition Width=”3*” /> </Grid.ColumnDefinitions> <TextBox Grid.Column=”0″ /> <TextBox Grid.Column=”1″ /> </Grid> This will make #1 … Read more
Every Control in WPF has a default Style that provides, among other things, the Control’s default ControlTemplate. WPF looks for the default style in a special resource dictionary in the Themes folder in the same assembly as the control. The key for the default style is provided by the Control.DefaultStyleKey dependency property, the default value … Read more
You may want to consider trying a new property available now in WPF4. Leave the RenderOptions.BitmapScalingMode to HighQuality or just don’t declare it. NearestNeighbor worked for me except it led to jaggy bitmaps when zooming in on the application. It also didn’t seem to fix any glitches where icons were sizing in weird ways. On … Read more
Since your ObservableCollection is created on UI thread, you can only modify it from UI thread and not from other threads. This is termed as thread affinity. If you ever need to update objects created on UI thread from different thread, simply put the delegate on UI Dispatcher and that will do work for you … Read more
If you want your application to open the link in a web browser you need to add a HyperLink with the RequestNavigate event set to a function that programmatically opens a web-browser with the address as a parameter. <TextBlock> <Hyperlink NavigateUri=”http://www.google.com” RequestNavigate=”Hyperlink_RequestNavigate”> Click here </Hyperlink> </TextBlock> In the code-behind you would need to add something … Read more
The ConverterParameter property can not be bound because it is not a dependency property. Since Binding is not derived from DependencyObject none of its properties can be dependency properties. As a consequence, a Binding can never be the target object of another Binding. There is however an alternative solution. You could use a MultiBinding with … Read more