wpf

ColumnDefinition MinWidth doesn't work correctly

Hi, I'm using a Grid in WPF (xaml) and I'm have some strange effect when using the MinWidth property in a ColumnDefinition. For example, when I use 9 ColumnDefinition and every ColumnDefinition has the 'Width="*"' property and one of the middle columns also has a MinWidth property then the size of the other columns is wrong. Well, it's...

WPF toggle buttons with custom template not accepting click in correct area

I'm a relative beginner in the WPF space so I'm sure this will be the first of many questions! I have a series of toggle buttons all with a custom template designed to show an image with a transparent background that then becomes highlighted when the user toggles the button. I wanted to add padding around the content so that the highlig...

Problem with dependency property

I am trying to create a static property, and the only way I could find to do it, is using DependencyProperty. I have created the following fields in my class : public static readonly DependencyProperty UnreadMessagesProperty = DependencyProperty.Register("UnreadMessages", typeof(int), typeof(ErrorLog)); public int UnreadMessag...

Set form MinWidth and MinHeight based on child property

I'm writing an application in WPF using the MVVM pattern. In my application I've got an IPopupWindowService which I use to create a popup dialog window. So to show a ViewModel in a popup window you'd do something like this: var container = ServiceLocator.Current.GetInstance<IUnityContainer>(); var popupService = container.Resolve<IPop...

warning BC40056: Namespace or type specified in the Imports 'MS.Internal.Xaml.Builtins' doesn't contain any public member or cannot be found.

I have a WPF VB.NET project in Visual Studio 2008. For some reason, Visual Studio thinks that it needs to add an Imports MS.Internal.Xaml.Builtins to every auto-generated XAML partial class (= the nameOfXamlFile.g.vb files), resulting in the following warning: warning BC40056: Namespace or type specified in the Imports 'MS.Interna...

How to draw lines across cells in a WPF Grid.

Hi, I am trying to fill the Grid control with custom controls dynamically. After the grid is filled with elements, I need to connect these elements by lines. How do I achieve this.... Thanks in advance ...

Removing Icon from a WPF window

I am able to remove the window icon from WPF window using WinApi's, however I get the icon again in the application window when I run just the executable of the WPF project. How do I remove the icon? ...

WPF to Silverlight project conversion

I need to convert an existing WPF project to Silverlight. I know that there is no an automatic way of doing it. Could you share your experience and give advise regarding steps for this conversion and what pitfalls one should be aware of? ...

WPF - Color animation on Polygons

Hi, I'm trying to perform a color animation on the fill property of a polygon and getting this error - Cannot convert the value in attribute 'Style' to object of type 'System.Windows.Style'. Cannot resolve all property references in the property path 'Fill.Color'. Verify that applicable objects support the properties. Error at object ...

Controls appear inactive when changing content

I'm using a ContentControl to display various ViewModels, which all use DataTemplates for view generation. Now the problem is, after i change the content (by clicking on a hyperlink for example), things such as hyperlinks appear inactive (i.e. grayed out), until i click on the UI again. Is there any way to avoid this behaviour without ha...

Business application idea (any idea is a good idea)

I have to do this project for school, and the theme is "A successful business". And I'm really stuck because I have no idea where to start from. Initially the project was supposed to be some sort of educational thing, but the theme changed after 2 months of work on the previous project so now I have to start again from the beginning. I...

Label background animation at runtime with WPF

Hello, I would like to create programmatically an animation for the background color of a label but I have some problems. I have implemented the following code: Public Sub DoBackgroundAnimation(ByVal obj As Label) If obj Is Nothing Then Return Dim animatedBrush As New SolidColorBrush() animatedBrush.Color = ...

WPF: Dialog shows *under* the main window. How to get it to rise to the top?

I use this code to produce a print-preview window. using (XpsDocument doc = new XpsDocument(fileName, FileAccess.Read)) { FixedDocumentSequence fds = doc.GetFixedDocumentSequence(); using (var reader = new System.Xml.XmlTextReader(new StringReader(xaml))) { Window preview = System.Windows.Markup.XamlReader.Load(re...

Using PRISM, how do I display the view from another module, and access its properties to update its state?

I have two modules, one is a Header module, one is a Items module. I have a HeaderDetails view, which contains a region which is called 'ItemsSummaryRegion'. This region is registered to populate the region with the view ItemListView from the Items module. regionManager.RegisterViewWithRegion("ItemsSummaryRegion", typeof(IItemListView)...

How do I unit test errors in an IDataErrorInfo business object?

I am writing (attempting to write) unit tests for a WPF application. The business objects that the UI binds to implement IDataErrorInfo, such that when I set ValidatesOnDataErrors=True in my View xaml, the error indexer (this[]) is called anytime the setter for the bound business object is called. That part is great. Now if I call th...

WPF: How to apply a change to an Opacity/Background immediately? (WPF analog to WinForms Control.Update() method?)

I have a WPF app, upon clicking a button, the app goes into a calculation that can take 4-10 seconds. I'd like to update the opacity of the background and show a progress bar, during that operation. To do that, I use this code: this.Cursor = System.Windows.Input.Cursors.Wait; // grey-out the main window SolidColorBrush brush1 = ne...

WPF: Read XML Data Island from Code-Behind

Guys, I have a Window with an XmlDataProvider containing a data island. I want to read the XML from the code-behind. I have inspected all the properties of XmlDataProvider. I must be missing something. How can I do this? My Code-Behind: //how do I get the XML data island into a string? This does nothing... var s = sp.Resource...

WPF Properties on View Model Interface?

Using "vanilla" WPF (no MVVM framework like Prism). Let me say up front that I absolutely advocate coding against abstractions/interfaces vs. implementations whenever possible. In WPF, when you do your bindings in the view, you are really not coding your bindings against the viewmodel interface. You are really binding against an imple...

Bind ListBox to XmlDocument

Could someone help me out, to why my listbox is empty? The XmlDocument contains the following XML: <Config> <Tabs> <Tab Name="Test1" /> <Tab Name="Test2" /> </Tabs> </Config> In my XAML file I have tried the following <Window> <Grid> <ListBox DataContext="{Binding {StaticResource Data}, XPath=//Tabs}" ItemsSource=...

How to generate and print large XPS documents in WPF?

I would like to generate (and then print or save) big XPS documents (>400 pages) from my WPF application. We have some large amount of in-memory data that needs to be written to XPS. How can this be done without getting an OutOfMemoryException? Is there a way I can write the document in chunks? How is this usually done? Should I not ...