A task was canceled

I am running a task. When closing the window i am trying to cancel the task using cancellation token source. The error does not occur every time the window is closed. Only sometimes. Please take a look at the error I am getting private Cancell...
more »

2017-04-17 22:04 (1) Answers

How acced to checkbox into listbox

I'm trying make a listbox with checkboxes into it. On xaml I have: <ListBox ItemsSource="{StaticResource ResourceKey=lstMaterialesCL}" SelectionMode="Multiple" Name="lstMaterial" > <ListBox.ItemTemplate> <DataTemplate&...
more »

2017-04-17 20:04 (4) Answers

Why is my FileSystem Watcher not firing events?

I create a FileSystemWatcher on a separate thread to monitor a directory for changes. None of my events fire when I add a new file or copy a new file into the directory that I am trying to monitor. I've used the FileSystemWatcher class successfully...
more »

2017-04-17 12:04 (1) Answers

c# wpf datagridview selected row

I got a datagridview with a information of customers. I have background data which I don't represent on datagridview. I try to get customer id on a selected row in datagrid. I try to use this code, but I got an error at converting datagrid.SelectedIt...
more »

2017-04-16 22:04 (2) Answers

Images not showing in FlowDocument

I'm struggling getting images to appear in a FlowDocument that is printed to PDF, to XPS or to a printer. I've studied this question, Missing images in FlowDocument saved as XPS document, but find the answer unsatisfying. Here is my code... ...
more »

2017-04-16 22:04 (2) Answers

Null pointer when switching between data grids

In a program I'm writing, there are two data grids on wpf form. One contains pet owners and the other contains the actual pets. When the user clicks on an owner, the pet data grid is populated with pets they own through a SQL database. The currently ...
more »

2017-04-16 10:04 (2) Answers

How to bind int to Visibility in WPF?

I have BudgetControlType Properties that has 1 .. 7 value if(BudgetControlType ==1) dataComboBox1.Visibility=Visibility.Visiblile; dataComboBox2 to dataComboBox7 =Visibility.Hidden; if(BudgetControlType ==2) dataComboBox1.Visibility=Visibility.V...
more »

2017-04-16 08:04 (2) Answers

How to avoid repetitive XAML?

I am currently in the process of creating simple application using WPF and C# (as a learning exercise). I've noticed that I am gonna need two almost identical Pages (same user controls, same list, same methods for buttons etc). The thing which is go...
more »

2017-04-15 19:04 (1) Answers

WPF Built-In Dynamic Resources

I'm trying to modify a copy of the style template for ContextMenu. There is the following line - <Setter Property="Background" Value="{DynamicResource MenuPopupBackgroundBrush}"/> How do I find the definition for the DynamicResource MenuPopu...
more »

2017-04-15 13:04 (1) Answers

How to bind Command to Check Box in ListView WPF?

Update I edited the code below to match the suggestions and it works correctly now. I've seen several stack overflow questions similar to this one, but I haven't quite been able to put it all together. I have the following xaml code. <UserCont...
more »

2017-04-14 20:04 (2) Answers

Command Binding WPF VB.NET

Help me resolve command binding issue that I'm having with ToggleHeightMeasurementOn Property (see code below). For some reasons, content binding is working, But command is not binding. View Code <UserControl x:Class="HeightMeasurementSelector...
more »

2017-04-14 16:04 (0) Answers

Not scoping static vars properly in C#

I'm new to C# - this is nearly my first program. I'm trying to create some public static variables and constants to use anywhere in the program. The - wrong - way I have tried is to declare them in a separate class in the same namespace but they are ...
more »

2017-04-14 15:04 (2) Answers

WPF example from a book - I get an exception error

I am learning WPF and running an exercise from a WPF book for the 1st time. This is the authors code so I expected it to work. I run the app and I choose the menu item before selecting anything. I would expect to get the error to pop up - "Specify a...
more »

2017-04-13 21:04 (1) Answers

WPF Treeview With Templates: Expand at design time

I have a multi-level WPF TreeView that uses HierachicalDataTemplate to bind to my view model. I want to see how the tree will look fully expanded at design time, but since the designer doesn't allow you to click on the nodes, I have been trying to fi...
more »

2017-04-13 18:04 (0) Answers

Why aren't WPF controls private by default?

In WPF, writing <TextBlock x:Name="foo"/> will make the control public. To make it private, one must explicitly specify the FieldModifier: <TextBlock x:Name="foo" x:FieldModifier="private"/> I find this strange. I don't think it is ...
more »

2017-04-12 06:04 (1) Answers