wpf

Determining which CustomPopupPlacement was used

I am using a WPF Popup with a custom placement. I know how to return mutiple CustomPopupPlacements from the callback. My problem is that I'd like to draw my popup differently based on which CustomPopupPlacement was used. Based on which one is actually chosen ( due to position on screen, etc ), I want to draw my popup differently. See i...

problem sorting ListView by column

I'm having some problem figuring out which listview column header was clicked on. In the XAML, I have this: ListView Name="myListView" ItemsSource="{Binding MyItemList}" GridViewColumnHeader.Click="ListView_Click" And once there is a click on the column header, I handle it like this: private void ListView_Click(object sender, Routed...

Style a button to match the current theme for the expand/collapse button on a TreeView

As you know, the built-in themes all define styles for the standard controls such as the TreeView control. We're trying to create something that looks an awful lot like a TreeView but isn't actually one, nor is it a subclass of one. It just has parts that we want to look like one for consistency. For instance, our control too has a se...

In C# (WPF) does databinding occur when the datachanges in the UI thread immediately?

I'm creating an application and I've been under the assumption that when a control is bound to a member in the view-model (i.e. a TextBox to a string field) the string is updated whenever the user changes the information in the textbox and no later. But what I've found is that the string is updated when the textbox is changed AND when t...

MVVM-Light What about events?

I started using MVVM-Light with WPF yesterday and it really makes a difference when it comes to structuring the code. But now i'm trying to figure out how to handle event. Lets say I've got this view, with a TabControl. In every TabItem i have a ListBox. Now how do i handle the event SelectionChanged? And to mess things up, can i send ...

Triangle-Indices in WPF

I have five generic list. Which contains objects of Point3D. I want to make TriangleIndices from that generic lists. Is there any Simple way? ...

How to construct a new WPF form from a different thread in c#

I'm having trouble with the concept of threads and how to use them. I'm trying to code a fairly basic chat program (as part of a larger program) and it currently works like this: The 'NetworkSession' class receives the input from the server on a separate thread in a loop. If it receives input that indicates it should open a new chat wi...

How to access bound resource after sorting gridview WPF

Hi I am binding an observable collection to my gridview. public ObservableCollection<LibraryTrack> Biblio { get { return _Biblio; } } The gridview only contains the necessary values for the user to see. The secondary information like filelocation and file id isn't bound to the gridview, this info is in this case useless for ...

Bind a calculated value somehow to a datagrid

Hello... I have a dataset which i bind to datagrid from wpf toolkit(forced to use .net 3.5).. I was ignorant as newbie to WPF and C# and didnt bind a collection of my objects,that would help a lot and would solve my problem! So the cell is something like that <my:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBloc...

WPF RichTextbox remove Foreground information from TextRange

Hey, sorry for my bad english... The default for a RichTextBox content is to inherit the Foreground color from the richtextbox itself. Thats nice, but if i set an especific color to some part of my text, that part do not inherit the foreground anymore, obviously. Now how can I make a part of that "colored" text inherit the parent color a...

WPF UserControl inside another UserControl

I'm looking to set a UserControl to be the Content of another UserControl in XAML, in the same way you can set a Button's Content to be anything. Let's say my "outer" UserControl looks like this: <MyUserControl> <Grid> <Border FancyPantsStyling="True"> <-- I want to insert other controls here --> </Border> ...

Make a Dialog ViewModel binding ready, call Dialog and return data from it in MVVM

Hello, Do you see a better way how I can call/contstruct a Dialog from a Controller/ViewModel return data from it and set the DocumentViewModel as DataContext of the Dialog? The problem is I can not use View first approach in the DocumentDetailWindow and its belonging UserControl because I can not set the Model to the DocumentViewModel...

Send an IOrder from ViewModel1 to ViewModel2 with a Messenger, how do you differentiate ADD/DEL ?

Hello, I have a CustomerListViewModel and a OrderListViewModel. In the latter I select an order to delete it or I create a new one. In both situations my CustomerListViewModel and the Messenger must register to the type IOrder: Messenger.Default.Register<IOrder>(this, AddOrder); Messenger.Default.Register<IOrder>(this, DeleteOrder); ...

User Control Margins

I have created a UserControl that contains an Ellipse and a few lines. I have drag and dropped them to position them how I like, but when I use the control on another page, the margins are relative to that page and not the user control so they are way off. Is there a way to force the margins to be relative to the user control and not h...

How to access inner TreeViewItem nodes without expanding the parent node

Hello, I have a WPF TreeView that is bound to a collection of custom objects - each of which has an IsExpanded property to expand the container TreeViewItem. I want to be able to programmatically access each TreeViewItem's control contents without expanding the parent TreeViewItem in the visual tree. However, when I attempt to access sa...

How to bold & add "*" to TextBlock when Tab Can be saved

I have tabs representing documents, something like in Word. My TabControl is bound to an ObservableCollection<TabViewModel>. TabViewModel has a property CanSave indicating whether a document can be save. When it can be saved, I want to bold it and prefix it with an "*". How can I do this? I think I need to 1st make CanSave a DependencyPr...

C#: Extending from more than 1 class

Suppose I have a ViewModel TabViewModel that Extends ObservableObject the class for ViewModels in the MVVM Foundation Framework. Then I also have a EditorTabViewModel that extends TabViewModel, Now I need to extend DependencyObject to implement DependencyProperties. I cannot extend more than 1 class. How might I implement this? I could h...

WPF Binding Alternatives / Enhancements

I love WPF bindings, but I often find myself wish I could do a little more. PyBindings seem like a good start, but the Python syntax seems very clunky and out of place in a XAML file. Are there any alternatives out there? Something with a simpler syntax, that allows for quick comparisons & conversions so that I don't have to write (an...

Canvas zooming in WPF using code behind

Here the scenario is: I have a canvas with different diagrams drawn on it. Now the requirement is to zoom into the canvas using the code behind either using C# or VB. Moreover I need to place the zoom code in some dll so that i can reuse the same set of code through out my application. Now my question is how to do this.... I have tr...

Am I using DependencyProperties wrongly?

I have declared my dependency properties as follows public bool CanSave { get { return (bool)GetValue(CanSaveProperty); } set { SetValue(CanSaveProperty, value); } } public static readonly DependencyProperty CanSaveProperty = DependencyProperty.Register("CanSave", typeof(bool), typeof(EditorTabViewModel), new PropertyMetad...