wpf

Moving to new record on Collection

I'm just getting started with collections (ObservableCollections) and I've hit a wall that I assumed would be easy. I'm sure it is easy but I'm just not finding the answer. I have a WPF screen with a DataGrid to the left and TextBoxes to the right of the screen. The DataGrid is bound to the ObservableCollection (Activities) and I can c...

Confusion regarding MVVM pattern and dynamic loading of XAML in GUI.

Well this question relates to MVVM pattern and i could good and fast answers on this forum so I thought to ask and clear the confusions i had about the pattern. I am quite new to MVVM approach. I appreciate the pattern and understand the principals behind it. Maybe I have not worked that much with the pattern that’s why there are a few ...

Mask all elements of a window/canvas with C#/WPF

Hi, How can I create a mask to cover ALL the elements of a Windows/Canvas (with subcanvas/elements inside)? Thanks in advance EDIT: I want to add more controls/elements/whatever after I create the mask. Is that ok? How? ...

Load external font and use it in C#

Hi, I'd like to load a font from an external server and once is loaded (I guess that's necessary) use it to create a few textfields. I'm trying: font_uri = new Uri("http://localhost/assets/fonts/wingding.ttf"); bf_helvetica = new FontFamily(font_uri, "bf_helvetica"); TextBlock test_tb = new TextBlock(); test_tb.Text = "This is a test...

Collection property for WPF usrecontrol

Hi I want to create a usercontrol in WPF through which i want to expose a collection property. I want to change the UI of the usercontrol based on the changes in collection. For example lets say i have a collection of strings which is binded to my usercontrol. Based on that collection i want to create buttons on the usercontrol contain...

Combined solidcolor brush

Is there a way to create a kind of "solidcolorbrush" that is a mixture of 2 solidcolor brushes? For the back color, i would like to be able to use a DynamicReference to some other brush. While the other color (in the front) could be a static color with opacity. Feel free to ask for clarification if this doesnt really make sence! Edi...

How to provide multiple conditions for data trigger in WPF?

How to provide multiple conditions for data trigger in WPF? ...

Combined solidcolor brush

Is there a way to create a kind of "solidcolorbrush" that is a mixture of 2 solidcolor brushes? For the back color, i would like to be able to use a DynamicReference to some other brush. While the other color (in the front) could be a static color with opacity. Feel free to ask for clarification if this doesnt really make sence! ...

Choosing C# with WPF for Ultra-Long-Term Project?

Hello, I'm involved in a project where a team of developers is building a very long term infrastructure project to replace an existing 10 year old system. By "very long term" I mean it must be operating, supported and maintained for at least 10 years into the future from the point of release. Taking into account ~2 years of development,...

WPF Prism V2 Using M-V-VM - Add a view at runtime to a region from the ViewModel

Hi All, Hopefully quite a simple one, having my first try at WPF with Prism V2 using M-V-VM and so far finding everything pretty awsome. My Shell is pretty simple, Ribbon Control at the Top, DataGrid of Help desk tickets on the left, and a TabControl on the right. When a user opens the selected ticket from the datagrid, I want the Tic...

what is the best way to emulate XAML code inheritance?

I have a number of UserControl classes: DataTypeWholeNumber DataTypeLine DataTypeDate DateTypeDuration etc. They all inherit from a plain C# class which inherits from UserControl which has no XAML attached to it. I had to do it this way since I was getting errors saying that XAML could not be inherited. The problem is that the XAML ...

WPF: finding the location of an element

Before answering, it is not as easy question as you might have thought about when you read the title. I have an ItemsControl which is binded to an ObservableCollection of T and data being described as a DataTemplate. So far it is a classic case. When I add a new element I need to know the exact coordinate and positions inside the windo...

Confirmation on switching between tabs.

I have two tabitems. User will enter some data and save it on the first tab. The second tab lists the saved data. What I need is when the user select the second tab before saving data in first tab a confirmation message box with Yes, No and Cancel should be shown. If the user clicks Yes button the data should be saved and go to the secon...

How to change the CultureInfo of a Converter?

Hello, I have a UserControl that displays some text of a DP of the UserControl. For this a converter is used. I understand that the culture parameter is the "en-US" culture, unless you specify a different culture in the ConverterCulture value of the binding or the xml:lang attribute. But how can I change to culture from outside of the ...

How can I access DependencyProperty values from my code-behind constructor?

I have a UserControl called SmartForm which has a DependencyProperty called Status. In my Window1.xaml, I have the element <local:SmartForm Status="Ready"/>. I would think then in the constructor of the SmartForm object, that Status would equal "Ready" but instead it equals null. Why is then the value of the Status property NULL in th...

How can I find out whether method executes on UI thread or not in a decoupled way?

Here is the problem I have: I need to make sure an object is instantiated on the UI thread. If it is not, it should throw an exception. But how do I check inside a method whether it is running on the UI thread? Note: I do not want to pass any information into the object's constructor. The perfect candidate would be the DispatcherSynchro...

WPF DataContext does not refresh the DataGrid using MVVM model

Project Overview I have a view which binds to a viewmodel containing 2 ObserverableCollection. The viewmodel constructor populates the first ObserverableCollection and the view datacontext is collected to bind to it through a public property called Sites. Later the 2ed ObserverableCollection is populated in the LoadOrders method and t...

WPF Basics: Shared global styles for MVVM

Hi, I am attempting to use an MVVM-ish approach to my WPF development. I have my logical view model classes under the ViewModel namespace, and I have matching styling for these view model classes under the View namespace. For now I have my View information in ResourceDictionary XAML files, as DataTemplates and Styles, which are all me...

In XAML, how can I keep an ellipse being a circle?

I'm getting XAML-blind I'm afraid. I'm developing a MS Surface application and I have an ellipse inside a ScatterViewItem (a container an end user can resize). I would like to keep the ellipse a circle (width == height) and keep it as big as possible (the lowest value of width/height of the SVI should be taken for both width/height prope...

Using WrapPanel and ScrollViewer to give a multi-column Listbox in WPF

Hi I’m making a simple LOB app which loads data from an XML file and displays it in a list with a few buttons for editing. In my first attempt, everything was ok except that the list scrolled downwards in one long column. I would prefer the data to wrap so that at the bottom of the Window it starts a second column, and so on – if you r...