wpf

Treeview Item Loses Selection When Focus Is Lost

I have noticed this on an application I am working on right now, so I created a simple test app to demonstrate. Below is my a window and the event handler for the treeview items. If you expand either the "One" or "Two" parent nodes, and click one of the children, the child that was selected does not show up as selected after the Focus(...

Viewbox in Cider designer hides all controls in the "box"

When I place a Viewbox as the child element of a WPF window, the Cider Designer "hides" all interior controls with the text "Viewbox" only appearing on the display. Why? Is there a problem with this layout? Are there better layouts to achieve scalable images on a canvas? <Window x:Class="WpfApplication1.Window1" xmlns="http://schem...

Improving WPF application speed over remote desktop?

In our scenario, we have a wpf application that is used by users over remote desktop, and we found the user experience is very slow. Any suggestions for improving the user experience in this scenario? One point might be to disable any animation/storyboards, and avoid using gradients in the UI. More thoughts are appreciated. ...

Why does DockPanel.Dock="Bottom" put element at the top?

The following code puts the two text elements at the top even though the second one is marked "Bottom". The background color goes all the way to the bottom so the DockPanel seems to stretch to the bottom. What am I not understanding about DockPanel? <Window x:Class="TestIndexer934.Views.MainView" xmlns="http://schemas.microsoft.com...

How can I make a XAML Slider element snap to allowed values only?

I have a slider with minimum value 0 and maximum value 1. When I currently slide it, the value gets set to a decimal value between 0 and 1, e.g. 0.2342343. However, I want the value to only be either 0 or 1 (so that my ViewModel property will register the change only if it is 0 or 1 and not multiple times as the user drags it from 0 to...

RegisterAttached String PropertyName causing AttachedProperty to not fire

I've run into an odd problem with attached properties where when I assign the property name in the call to RegisterAttached and name properly for the name of the attached property (say TranslateProperty and "Translate") the code for the attached property implementation doesn't fire. Just doesn't get called. If I change the string name to...

Let WPF UserControl delete itself and Data-Object which is bound to it?

Hello, I've placed in my MainWindow a StackPanel, which gets dynamically on runtime new UserControls (the UserControl is a row of TextBoxes and a button named "Delete"). This is about how I create the UserControls: PersonObject p = new PersonObject; List.Add(p); UserControlLine usrCtrlLine = new UserControlLine(); usrCtrlLine.DataCont...

Syntax colouring in WPF

Hi, Does anyone know if there's a free WPF syntax highlighting component? I'm currently using AvalonEdit, which is part of the new SharDevelop source. The trouble I'm having is that it doesn't appear to support binding for the text content. Does anyone know if this is possible or if there's any other similar controls that do support da...

Why does WPF Binding update strings but not objects?

In the following code example, you can move the slider from German to English and see that text block get translated at runtime, however: only the TextBlock bound to a string gets updated the TextBlock bound to a Dictionary does not get updated It seems that the View simply gets the Dictionary object once and then doesn't update anym...

Prism CAG - WPF - New instance of Modules? Is it just cloning instances?

I am developing a WPF application using the CAG from Prism. What I want to achieve is create new instances of a module (ModuleA) and load them in a TabControl. I am able to instantiate the modules using the moduleInfo object and loading them through the Assembly and calling the CreateModule(type) method. I can actually see the differen...

Using XAML vector graphics in WPF application

I have a vector image that I've defined in XAML. What is the proper way to use this resource in a WPF application? I want to have the vector image in its own XAML file, and then add the image to other UserControls in my application. What should be the top-level element in my XAML vector image? How do I refer to that image in other UserC...

Get Data from ObjectDataProvider when combo box opens

How do I go about getting an ObjectDataProvider to get triggered each time a combo box is expanded instead of just one time? <UserControl.Resources> <ObjectDataProvider x:Key="possibleExpressionValues" MethodName="GetWatchVariableNames" ObjectType="{x:Type mu:UserInterfaceHelper}" IsInitialLoadEnabled...

How can WPF Converters be used in an MVVM pattern?

Let's say I have a View that is bound to ViewModel A which has an observable collection Customers. An advantage of this MVVM pattern is that I can also bind the View to ViewModel B which fills it with different data. But what if in my View converter Converters to display my customers, e.g. I have a "ContractToCustomerConverter" that ac...

How to declare a resource from a private inner class in WPF?

Hi, all. I'm trying to declare a resource in a WPF UserControl, and I'd like the resource to be an instance of a private inner class. How do I do this? XAML: <UserControl ...> <UserControl.Resources> <local:MyConverter x:Key="MyConverter" /> </UserControl.Resources> </UserControl> Code Behind: public partial class M...

ObservableCollection Databinding performance

I would like to know why according to this article and observable collection binds significantly faster(20 ms vs 1685ms, that's 800X faster) than a List<> collection in WPF. I looked at the internals of ObservableCollection and it uses a List as it's storage collection object(I used reflector and saw this in the constructor) public Coll...

Should your ViewModel expose XAML elements as properties or not?

Over at the StackOverflow question How can WPF Converters be used in an MVVM pattern? I've learned that Value Converters should not be used in the MVVM pattern since the functionality of a Value Converter should be handled by the ViewModel itself. This makes sense. But I remember reading that you should not expose XAML elements to the ...

In WPF how can you draw a line over a WindowsFormsHost?

Here is my XAML <Grid Name="grid"> <TextBlock Text="Some Label" /> <WindowsFormsHost Name="winFormsHost"> </WindowsFormsHost> </Grid> On the load of the form I execute the following method protected void OnLoad(object sender, RoutedEventArgs e) { // Create a line on the fly Line line = new Lin...

WPF printing to a Device Context

Is there a way to print a WPF screen directly to a Device Context? In other words, is it possible to design a layout using WPF and then write that layout to a Device Context? Thanks! ...

Access existing WPF app instance?

Okay, here's my situation. I have a WPF app that I have created that also includes an application protocol handler so that the app can be opened from links on the web that opens the app with command-line parameters to pre-populate some information. All this is working. What I would like to accomplish is this. If the user already has ...

Creating a custom control that is a Button that also has a Items and ItemsSource?

I'm trying to create a SplitButton control that uses a ContextMenu to display its items. The SplitButton is currently deriving from Button. I have a PART_DropDownInitiator that is the little icon the user clicks on to bring up the ContextMenu for the SplitButton to show its items. The problem is that I'm trying to setup a default Contex...