wpf

Open new Page from an Xbap

Our application is an Xbap running in full trust. I have a function similar to this: private void ShowPage(Page page) { NavigationWindow mainWindow = Application.Current.MainWindow as NavigationWindow; mainWindow.Navigate(page); } This works great for browsing inside an existing window. I would like to open this new page in ...

How do I place/scale a XAML graphic in my application?

I'm working on a simple application to start learning my way around WPF. I created a vector graphic in Microsoft Expression Design at 400px by 400px, mainly because I thought it would be easier to create it on a bigger canvas. I've exported the image to a XAML file as a series of objects within a 400px square canvas. All of the child ob...

IoC and User Interfaces

I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue. I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTask for EmployeePresenter) are...

c# WPF Maintain Single Instance of loader

I have a loader.exe with Main() that loads the 'UI' in WPF, the thing is that I want only one instance of the loader.exe, how can I achieve it? Is there a way a user clicks loader.exe it should check if an existing loader.exe is running and does nothing. currently I have loader.exe with main() .... .. Load UI ... the loader h...

WPF: Can I restyle a checkbox template, so that the checkindicator is a red cross instead

I can´t find a way to restyle the IsChecked indicator of a checkbox. As I can see from the checkbox template there´s no possibilities to restyle the indicator, just the "box" of the checkbox. Does anyone knows if it´s possibly to restyle the IsChecked indicator? ...

How to update appSettings in a WPF app?

Greetings to all! This is my first question here on stackoverflow. I have a WPF application that I am writing for the fellow developers in my department, and there are a couple of settings that I need to check for at startup and update if they are not set (one is the location of an executable on the users computer, we all have it, just...

How can I indicate in an Expander header that collapsed contents have an error

Hi, I have expanders that contain text boxes, the text boxes use the wpf validation stuff to draw a red box around them ( text boxes are wrapped in Adorner Decorators to make sure I don't get empty red boxes everywhere when the expanders are collapsed) I want to indicate in the header of the expander that it has contents that have erro...

WPF richTextBox question

If a line of text is wrapped to an additional line, how do I determine programmatically the point in the string where it was broken. Example: Input string = "This is a test of a wrapped line of text". Based on the width of the richTextBox it could display: This is a test of a wrapped line of text. What...

WPF XAML Global Reference

Is there a way to reuse a 3rd party control reference? For example, I have this referenced in my App.xaml xmlns:cust="clr-namespace:ThirdParty.Controls;assembly=ThirdParty.Controls" I don't want to repeat this 3rd party control xml namespace on each page/control that needs a control from the library. Is there anyway to centralize ...

Changing the cursor in WPF sometimes works, sometimes doesn't

On several of my usercontrols, I change the cursor by using this.Cursor = Cursors.Wait; when I click on something. Now I want to do the same thing on a WPF page on a button click. When I hover over my button, the cursor changes to a hand, but when I click it, it doesn't change to the wait cursor. I wonder if this has something to d...

Binding to an element within a UserControl

Say I have a user control like the one below, how would I bind something to the ActualWidth of the "G1" grid from outside of the control? <UserControl x:Class="Blah"> <WrapPanel> <Grid x:Name="G1"> ... </Grid> <Grid> ... </Grid> </WrapPanel> </UserControl> ...

Passing data to .NET C# WPF applications/DLLs

Hello! I have a .NET C# WPF application that I am trying to make into a single-instance application using a Mutex. This .NET application is called by a C++-based DLL using CreateProcessAsUser() and is given parameters via environment variables. Subsequent instances will also be created by the C++ DLL in the same way. Subsequent ins...

Manipulating a WPF element tree

Is it possible to manipulate the controls tree of a WPF window programatically? I have a string that contains an arbitrary WPF XAML code. I show the content in a content control. No Problem so far. Additionally I want to decorate every Grid control that's contained within the XAML snippet with let's say a special Border. What are pos...

Debug and Release Assembly Refrences in XAML

In a XAML namespace declaration, is there a way to disambiguate differently named assemblies depending on your current configuration? I'm in the process of reworking a projects build system. The old system had the debug and release assemblies building to seperate directories, which meant the following (roughly) would work fine at the t...

Recursive HierarchicalDataTemplate (WPF)

I'm not sure how to approach this: I want a TreeView that will display some simple data from a hierarchical data structure. As a basic example (In XML, cause it's easy to type): <Node text="Root"> <Node text="Item 1"> <Node text="Item 1.1" /> </Node> <Node text="Item 2"/> </Node> The catch is that this could theore...

WPF Tab View, Custom Templates, and Accessibility

I'm having a problem with the WPF Tab View control that I was hoping someone here might be able to help me with. I want my tab view control to use rounded corners for the tab headers, because I think rounded tabs look better. To do this I modified the default control template for the tab by using the "Edit Copy" command in Expression B...

WPF Binding Collection To ComboBox and Selecting an item

I've been knocking my head against this for some time now. I'm not really sure why it isn't working. I'm still pretty new to this whole WPF business. Here's my XAML for the combobox <ComboBox Width="200" SelectedValuePath="Type.FullName" SelectedItem="{Binding Path=Type}" Name="cmoBox" > </ComboBox> Here's what populates the ...

Add WPF control at runtime

I've written a WPF UserControl, and want to add one or more of it to my Window at runtime when I click a button. How can I do that? Edit: Further specification I want to add the usercontrols to a Canvas, and put in a absolute position. The canvas is a drawing of the floors in my house, and each usercontrol has properties to indicate whe...

Wpf custom control template - relative font size

I am creating a custom WPF control that let's say for simplicity sake has a vertical stack panel with a "title" TextBlock, followed by a ContentPresenter. I want the font size for the "title" to be 5 Points LARGER than the size used in the content, which is inherited by whatever container the user places this control in. How can I speci...

WPF - Pass the value of one control to a Converter to set the width on another control

I want to set the width of a TextBlock based on the width of its container, minus the margins set on the TextBlock. Here is my code <TextBlock x:Name="txtStatusMessages" Width="{Binding ElementName=LayoutRoot,Path=ActualWidth }" TextWrapping="WrapWithOverflow" Foreground="White" Ma...