wpf

Best place to bring up new window in Model View ViewModel

I have an MVVM application. In one of the ViewModels is the 'FindFilesCommand' which populates an ObservableCollection. I then implement a 'RemoveFilesCommand' in the same ViewModel. This command then brings up a window to get some more user input. Where/what is the best way to do this whilst keeping with the MVVM paradigm? Someho...

databinding tooltip in listbox

Hi, I am working with binding an xml structure to a listbox. I am quite confused hoe to do this.How to put a datatemplate inside a datatemplate or i need to use a hirarchialdatatemplate...for example from the xml, I want to display the Make Name of the cars in a list box and i want to show the corresponding Suvs's as a tooltip or context...

WPF - Can I stop UserControl exposing its named child elements?

This is a bit of a noob question but I've just realised that if i create a UserControl and choose to name some of its child elements a la - <UserControl x:Class="UserControls.uControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300"> <Grid...

How do I pass a property changed event to an ancestor?

I'm sure I am missing some of the basics here so please bear with me. I have a two objects, a SalesOrder and a SalesOrderLineItem. The lineitems are kept in an Observablecollection<SalesOrderLineItem> of SalesOrder, and if I add line items my databound listView knows about the new items. Now where I am having a problem is here: The Sal...

WPF WinForms Interop issue with Enable / Disable

I have a WinForms usercontrol hosting a WPF custom Listbox in it. After the WinForms user control gets disabled and then re-enabled the WPF control in the WinForms usercontrol is unresponsive. Has anyone else experienced this? We had to hack a soultion into remove and re-add the element host each time the control gets disable / enable...

How do I read from standard input in a WPF application?

I'm trying to figure out how to read from the standard input stream of my own WPF application but I can't find a way to get the stream. The standard way to do it, Console.ReadLine() returns Null(Nothing) immediately. I'm assuming because it's not a console application and no console window is open. How can I read from standard input ...

ProgressBar not updating on change to Maximum through binding

<ProgressBar Foreground="Red" Background="Transparent" Value="{Binding NumFailed, Mode=OneWay}" Minimum="0" Maximum="{Binding NumTubes, Mode=OneWay, Converter={x:Static wpftools:DebuggingConverter.Instance}, ConverterParameter=Failedprogressbar}" FlowDirection="RightToLeft"...

Maintain Selection State After Changing Backend Collection in ListView

I have a listview control that is bound to an observable collection that I frequently update. When I update the collection, I clear the collection and then add the values. While this is a bit overkill for simple changes, it's very simple and accomplishes the job. In doing so, I lose which item was selected in my listview control and cann...

Is It Possible To Create A Cursor In WPF From a VisualBrush?

I'm doing some Drag and Drop operations, and I want to use a visual copy of the element I'm dragging for the cursor. It's easy enough to get a VisualBrush of the element, but I have no idea how to turn this into a cursor. I've read the Jamie Rodriguez blog posts, but his solution isn't quite what I'm looking for because he essentially ...

WPF Text Formatting in GridViewColumn

I want to apply a format (align text, format for the currency 0000.00) to the columns in the GridViewColumn. <GridViewColumn TextBlock.TextAlignment="Center" Width="80" DisplayMemberBinding="{Binding XPath=Name}"/> The idea is the following one: In the columns (GridViewColumn) the text that our could apply a format to him (Aligners o...

Is it possible to 'refresh' WPF data bindings

I've got a xaml TabControl and on one page, there are 3 RadioButtons each bound to a different property on the selected value of an adjacent ListView. After switching between selected items in the ListView, my radio buttons seem to forget they're bound and don't refresh. So watching it in the debugger, when I switch to a new selected it...

Why the Overhead for Multi Threaded Access to WPF UI controls?

Have I missed something with WPF (and Windows Forms before it) in regards to the need to write a lot of repetitive code when developing multi-threaded applications. Every UI control in the application ends up needing extra lines of code to get and set each property. internal delegate void SetElementIsEnabledDelegate(UIElement element, b...

PropertyChanged for indexer property

I have a class with an indexer property, with a string key: public class IndexerProvider { public object this[string key] { get { return ... } set { ... } } ... } I bind to an instance of this class in WPF, using indexer notation: <TextBox Text="{Bin...

How to resolve: WPF access keys intercepted by IE

We have built a XBAP application and have given the access keys (keyboard shortcuts) on labels/buttons. But IE seems to capture the access key first and hence the application does not get a chance to handle the access keys. Is there any workaround/solution so that XBAP application overrides the access key of IE? ...

control to interchange UIElements in WPF

What is the most minimal way to dynamically interchange UIElements at a certian "slot" on the UI? I have a number of UIElements and based on some external databinding (e.g. a combobox selection) I want one of them to be shown and the one that was currently visible to be hidden. So the behavior is sort of like the tabcontrol but without t...

How do I set the size of a WPF window based on a desired client area size?

I know that in XAML/WPF, I can set the Window size using the Width and Height properties, but suppose I want to set the window size such that the client area (minus the Windows borders/decorations) will be a certain fixed size, what is the easiest way to do that? Like, suppose I want the client area of the window to be 640x480, ala this...

Declaratively set property of MyUserControl in MyUserControl.xaml

Assuming we have such control: public partial class MyUserControl : UserControl { public MyUserControl() { InitializeComponent(); } public string Foo { get; set; } } How can I set "Foo" property value declaratively in MyUserControl.xaml? <UserControl x:Class="Test.MyUserControl" xmlns="http://schemas.microsof...

OneWayToSource binding from readonly property in Xaml

I'm trying to bind to a Readonly property with OneWayToSource as mode, but it seems this cannot be done in XAML: <controls:FlagThingy IsModified="{Binding FlagIsModified, ElementName=container, Mode=OneWayToSource}" /> I get: The property 'FlagT...

WPF Datagrid - Check Visible Rows

I have a wpf datagrid (the one from the wpf toolkit), which when there are too many rows to view on the screen it gets a vertical scroll bar. What I would like to know is if there is a way to know what the top visible row is when the user is scrolling. Ideally I would like to be able to wire up to an event to know when the user is scro...

winforms newbie trying to get into wpf, looking for resources

I am brand new in the world of Wpf, and am thinking it's time to get into it for my next project. I'm a hardcore Winforms guy. Many of my projects perform tons of custom drawing - for example drawing a virtual baseball strike zone and then drawing icons to represent pitches thrown by a pitcher or seen by a batter. The pitches are in...