wpf

App.Current.MainWindow changes when launching another dialog?

I am launching a new dialog from a MEF plugin when I start up the application. Could someone explain why this changes App.Current.MainWindow to the dialog that was launched from the plugin? How can I prevent this from happening? ...

How to make listview update itself in wpf?

I realize this is kind of a long question, but I saw no other way here than to post my code, that I tried to keep as short and simple as possible for the sake of clarity. Of course tons of best practices are violated to do so, the example is long enough as it is.. I made a very simple wpf app that shows a list of Persons on the left ...

LINQ Refresh does not result in Changed Events

Is it just me or does changes produced by refreshing the LINQ DataContext not result in Changed Events? I have a multiuser Application which has an simple atomar locking system to prevent conflicts. So if an User changes something in the database I need to trigger Refresh on the Datacontext to reload the concerning objects. A breakpoin...

Can I set the content of a Label to a Binding Expression AND a static value?

Is there a way to set a Label's Content property to both a Binding Expression AND a static string value? I want to be able to display something like this: "Current Value: [Value From Binding]" I was thinking something like this would work, but apparently it doesn't: <Label Content="Current Value: {Binding ElementName=SomeTextBox, Pat...

ComboBox Binding in WPF

Hi, I am not able to set the selected value of a combobox. this is how i am doing. ComboBox x:Name="cmbProjectStatus" ItemsSource="{Binding ItemListCollection}" DisplayMemberPath="Name" SelectedValuePath="ID" SelectedValue="{Binding Path=ItemList.ID}" SelectedItem="{Binding Path=ItemList}" ...

Composite WPF EventAggregator subscriptions being lost

In my Composite WPF application I have an event that is published when the user double-clicks on a control. Modules subscribe to the event and perform an action when necessary. This event seems to stop working at random. Sometimes when I run the application I can trigger the event with no problems, other times I can only trigger it a fe...

ScrollViewer not scrolling in WPF

I am using a scrollviewer control around my stack panel which contains an ItemsControl. When there are many items in the ItemsControl it is suppose to scroll but for some reason it just cuts of the items. Here is the code: <StackPanel> <ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Visible"> <ItemsCon...

WPF Trigger to change Cursor

I need to change the cursor of a TreeViewItem in a trigger. This code works for all other properties but not Cursor: <Style.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="QuickPhrases:TreeViewChecker.IsMouseDirectlyOverItem" Value="True"> </Condition> <Condi...

MVVM with XML Model and LinqToXml?

Hi, I've been reading up on the MVVM pattern, and I would like to try it out on a relatively small WPF project. The application will be single-user. Both input and output data will be stored in a "relational" XML file. A schema (XSD file) with Keys and KeyRefs is used to validate the file. I have also started to get my feet wet with Lin...

How do I Convert a FormattedText String into a Geometry-Based Object?

How do I convert a FormattedText string into a geometry-based object? I don't think this question requires much explanation, and I can't think if very many other details I could give ... I just need to convert the FormattedText into something I can use mathematically (geometrically). Any advice is appreciated! ...

How to achieve focus-reset to update BindingSource of TextBox before any action

I have observed some unexpected or at least not-perfectly-matching-my-needs behaviour of textboxes bound to textproperties when I can't use using UpdateTrigger=PropertyChanged for my binding. Probably it is not an issue with the textbox but will occur with other editors as well. In my example (source code attached), I have a WPF TabCont...

Using Behaviors to Validate DataGrid values in Blend 3

Maybe it's the 3 hours of sleep (thank you Harry Potter) talking this afternoon but I cannot wrap my head around this. I'm trying to learn to use Expression Blend 3. And by learn, I mean do things in the "Blend way", using Behaviors and DataGrids and the new SampleData and all it's wonderfulness. I think it will be beneficial in the l...

Wpf combobox text property binding problem

I am trying to bind to a combobox text with the IsEditable property set to true. I have a property in my viewmodel which is bound to the text. I want to validate on the text being typed in the text of the combobox, and restrict some values that the user is typing in. So some will be allowed, and some not, and these need to set the com...

Not able to refer a control in code behind in VS 2008 with WPF

I don't know why but for some reason I am not able to refer to my tbText control in my code behind file. Here is the XAML part: <ComboBox.ItemTemplate> <DataTemplate> <ItemsControl x:Name="ic"> <Grid> <Grid.ColumnDefinitions> ...

How to make a custom WPF collection?

I'm trying to create a custom set of classes that can be added to a WPF control through XAML. The problem I'm having is adding items to the collection. Here's what I have so far. public class MyControl : Control { static MyControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(MyControl), new FrameworkPropertyMetad...

WPF Control actual size

Hello, I have this piece of XAML code: <Window x:Class="SizingTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <Label x:Name="theLabel" Width="Auto">A very large label with a lot of ...

WPF MVVM - Can a single PropertyChanged update all the Data bindings of a DataTemplate?

I have a ViewModel class which has large number of properties(Say 50). Once the data is set on to all the properties I need to update the UI. I know that the common solution is to raise PropertyChanged on all the property setters. I am wondering if there is any way I can notify my DataTemplate to update all its bindings through a singl...

silverlight 3.0 communication with winforms

I would like to create a winform on the client side for interaction with Silverlight 3.0. The basic idea is using the winform browser. I definitely need both the directions of communication. Would it be impossible by using JavaScript as a midware for the interaction or some better ways? Or is there any new features of Silverlight 3.0 sup...

How do i control clipping in c# or xaml when using UniformToFill with an image.

I have an image control in a resizable window with its stretch property set to UniformToFill. <Image Name="some_image" Stretch="UniformToFill" Margin="0,0,0,0" /> The clipping window is pegged to the top left of the image; resizing chops off the right and bottom of the image. I want the image to be clipped equally on all sides. Am i...

Append Items to Databound ItemsControl in WPF

I've got a Combo Box that is databound to an ObservableCollection of items. I would like to have a default selected item that is (None) that would set the value of the property I've bound to "SelectedValue" to null. I think there ought to be a way to achieve this with some combination of Style/DataTemplate/TemplateSelector. I'm trying...