wpf

By changing a window template all controls are gone

I want to change my window template, eg: <Style x:Key="SilverGreenWindowStyle" TargetType="{x:Type Window}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid Background="{StaticResource SilverGreenBackground}" Width="503" Height="383"> <Rectangle Margin="192,...

WPF simple tips-and-tricks?

I was fooling around with margins and padding and found that a negative value was acceptable and gives a nice effect in appropriate circumstances. For instance, if you have a border with a filled object and you want the filled object color to overrun the border. Anyone have any others? ...

Applying a DataTrigger to a Button Whose Binding Comes From Another Control?

Hi, I'm trying to apply a DataTrigger to a Button and it depends on a property from the currently selected item of a TreeView. The idea is that I want to change the text of a button depending on a property of the selected item. What I have looks like this: <Button x:Name="m_AddObject" Margin="192.708,0.909,6,6.363" Click="AddObject_C...

Preserving a bound WPF ListBox's scroll position when the collection changes

I have a WPF ListBox bound to an observable collection. When things are added to the collection, the listbox scroll position shifts by the size of the added entries. I'd like to be able to preserve the scroll position, so that even as things are added to the list, the items currently in view don't move. Is there a way to accomplish this?...

How to keep page with full state in navigation wpf app

I'm building a WPF app using pages and the navigation service. One of the pages take an object as a constructor Sub New(ByVal o As Object) ' This call is required by the Windows Form Designer. InitializeComponent() .... So, to navigate to it I do Dim MyPage As New Page1(MyObject) MyBase.NavigationService.Navigate...

WPF - Command in a MenuItem in a DataTemplate

I have a DataTemplate containing an Image. To the Image I added a ContextMenu with a MenuItem. To the MenuItem I associated a command. I then handle the command in the view using the DataTemplate. In the CanExecute handler I have e.CanExecute = true. But the Executed handler is never executed. If I remove the Command assignment the Men...

WPF - Making hyperlinks clickable

I've got a bit of text that I'm trying to display in a list. Some of those pieces of a text contain a hyperlink. I'd like to make the links clickable within the text. I can imagine solutions to this problem, but they sure don't seem pretty. For instance, I could tear apart the string, splitting it into hyperlinks and non-hyperlinks. ...

WPF Designer "Could not create an instance of type"

In my UI XAML I'm essentially inheriting from a class "BaseView" that contains functionality common to several forms, however this is preventing the designer from displaying the form: "Could not create instance of type BaseView". The code will compile and run, but it is frustrating not to be able to see the form in the Designer. Is ther...

Select All Checkbox in XAML using trigger?

Hi. I'd like to implement a select all checkbox in xaml. I have several (templated) checkboxes in a listview. Then I have a checkbox outside of the listview, which I want to have a "select all"-behaviour. I could easily solve the problem in my ViewModel, however, I think it would be more elegant to do this in xaml, since the select all ...

[WPF] How to get access to an element outside a style?

I have many buttons, all of them have the other Content (Polygons, Rectangles, Ellipses etc) Each Content's Fill and Stroke property use DynamicResources: <SolidColorBrush x:Key="ContentsBorderColorEnabled" Color="Red"/> <SolidColorBrush x:Key="ContentsBackgroundColorEnabled" Color="White"/> <SolidColorBrush x:Key="ContentsBorderColor...

WPF: How to fade-in and scale a user control in a popup

Hi, I have a user control that I'd like to show when the user clicks a button. That's not a problem, using af Popup control. However, I'd like to have the user control fade-in and scale from 0.5 to 1.2 and back to 1.0 (both X and Y) at the same time. How do I do that? ...

How can I edit immutable objects in WPF without duplicating code?

We have lots of immutable value objects in our domain model, one example of this is a position, defined by a latitude, longitude & height. /// <remarks>When I grow up I want to be an F# record.</remarks> public class Position { public double Latitude { get; private set; } // snip public Position(dou...

What is the best way to implement the graphics for a selected item in a WPF user control?

I have implemented a few different WPF user controls. In doing so I have also implemented a few different ways of implementing the graphics for when an item is selected. I want to find out how others are doing this and what they think is the best way of doing it? Only one solution per answer please. To avoid confusion here are some...

Hide listview header programatically.

I have a list view like Col1 Col2 Col3 1 A I 2 B II 3 C III I use 2 buttons. When click on first button the Col3 should collapse and it should be visible when a click in the second button. Any idea to do such a listview in WPF? ...

Free Wpf scheduler control

Is there any free scheduler control for WPF? I found ComponentOne and Telerik but they are not free. I need something with equivalent functionality that I can use in school project. ...

RelayCommand in wpf?

How to use RelayCommand in wpf? ...

Restrict the selection a WPF TreeView With Icons to Text only

I have a simple WPF TreeView with icons <TreeView Name="TreeViewThings" ItemsSource="{Binding}"> <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type local:Thing}" ItemsSource="{Binding Children}"> <StackPanel Orientation="Horizontal" Margin="2"> <Imag...

What is the advantage of setting DataContext in code instead of XAML?

There seem to be two main ways to define DataContext in WPF: either in code like this: App.xaml.cs (taken from the WPF MVVM Toolkit template): public partial class App : Application { private void OnStartup(object sender, StartupEventArgs e) { // Create the ViewModel and expose it using the View's DataContext ...

How do I install XamlPad?

This is going to sound silly, because everyone seems to take it for granted that XamlPad is just there, including the MSDN article about XamlPad. But I've installed Visual Studio 2008, which AFAIK installs the .NET 3.5 SDK (how could it not?), which is supposed to include XamlPad. But there is no XamlPad.exe in my Start Menu or anywhere...

Right Align MenuItems in WPF

Hi, Can i right align the menu items in WPF? Thanks Sharath ...