Questions tagged [wpf]

46601 questions
1

votes
2

answer
1.3k

Views

How to display objects from an observablecollection in a listbox based on a search string?

Thank you for reading my question. The situation: I have an ObservableCollection CheckableItems The class CheckableListItem has 2 elements: bool IsChecked and T Item. The class acts as a wrapper class that adds a checkbox to each Item. In this project the Item passed has a string element called Na...
Enrico
1

votes
1

answer
76

Views

Should I always use Command even though it might not be necessary?

Should I always use Command even though it might not be necessary? Or should I only use Command in the case where more things, menu items, buttons, whatever, when clicked execute the same code? Maybe it is good practice to always use Command, or maybe it adds additional unnecessary complexity. I am...
user2381422
1

votes
3

answer
4.8k

Views

Button Command Binding

I have a button inside a listbox. I want to bind the command to the DataContext of the Main Grid. I'm not sure who to do this, below is my attempt. I want to bind to ViewModel.SelectionEditorSelectionSelectedCommand on my view model, which the main grid is bound to, I don't want to bind to the actua...
DermFrench
1

votes
3

answer
4.8k

Views

How to change the height of the a WPF `<Separator />`?

I use the wpf in a list menuitems in a normal menu (not the context menu). Using the following style, the separator is not drawn: The value of Height must at least be 12, but then the distance from menuitems is too large. What is happening here? Is it logical? Is there a solution?
Gerard
1

votes
1

answer
2.2k

Views

How to Animate Button FontSize in Wpf?

I have one Button Name Button1. I want to change this button font size in animation. So I wrote code in Window_Loaded function. DoubleAnimation da = new DoubleAnimation(0, 25, new Duration(TimeSpan.FromSeconds(3))); //da.TargetPropertyType = "Width"; da.RepeatBehavior = RepeatBehavior.Fo...
Sagotharan
0

votes
0

answer
21

Views

Merging rows with negative values in datatable

I know there are might be many answers to the title, but my case is a little different. I've been trying to achieve the following, but I got stuck with my Linq. Any help would be much appreciated. I have 3 columns in Datatable1 as shown below. Item Quantity Store ItemA 12 S...
Wildchild
2

votes
2

answer
109

Views

WPF Programmatically Enable TextBox Scrolling/Panning for Tablets

I am working with a WPF application that will be used on Windows tablets. The issue I am having is that I cannot scroll through a large multi-line TextBox on a tablet by pressing and dragging the content. However, it still scrolls on a desktop with a mouse wheel. This question (Enable swipe scrollin...
Blake Nelson
0

votes
0

answer
5

Views

How export selected cells from Xceed.Wpf.DataGrid.DataGridControl to file?

I know how copy selected cells to clipboard by ApplicationCommands.Save. But i need to export this content to file or variable. How can i do it? PS: copy to clipboard and then get content from it - is bad idea, i think
vamireh
1

votes
2

answer
334

Views

Accessing dictionary items added by another thread

Here is my code - public partial class MainWindow : Window { ConcurrentDictionary Cache = new ConcurrentDictionary(5, 199); int width = 720; int height = 480; int stride = (width * 3 / 4 ) * 4 + 4; int currentframe = 0; public MainWindow() { InitializeComponent(); Thread t = new Thread(() => { while...
phil
1

votes
3

answer
213

Views

MouseUp / Click on Image does not work unless it has a Source

I have 15 images.. where I have "On Mouse Up", have it open up a windows explorer browser window so they can choose what image to put as the source. the thing is if there is nothing in the image source originally.. mouse up doesn't work... is there any way around this? private void Image_MouseUp(obj...
user1189352
1

votes
1

answer
1.4k

Views

How to determine if a Storyboard is animating

I'm trying to develop an application that starts a Storyboard only if it's not animating. Is there a way to determine if the Storyboard is animating or not?
John Kilar
1

votes
2

answer
1.4k

Views

BindingExpression path error for property in ViewModel

I have the below visibility binding that is throwing: System.Windows.Data Error: 40 : BindingExpression path error: 'Vis' property not found on 'object' ''LoginViewModel' (HashCode=22943289)'. BindingExpression:Path=Vis; DataItem='LoginViewModel' (HashCode=22943289); target element is 'Login' (Name=...
Hank
1

votes
1

answer
151

Views

How to truncate a control based on window width?

I want to resize a controls' width and content based on the size of its parent window. For example: When the window is resized to be smaller then 300 pixel wide I want to Borders to have a with of e.g. 30. How can I do that? Thanks
user1130329
1

votes
2

answer
621

Views

How to change background of DataGridCell when IsEditing=True in WPF

Setting background works fine for DataGridCheckBoxColumn but not for DataGridTextColumn. I set it for cell in resources: Is there any solution for this issue?
Artem Kyba
1

votes
1

answer
227

Views

Defining StackPanel resources programmatically?

I'm just poking around some WPF samples I found online, and came across an odd behaviour which I have simplified it below: If I un-comment line 3 (the resource definition) everything works great. However, if I comment that line out, and programmatically add the following: public MainWindow() { Initi...
maxp
1

votes
1

answer
1.5k

Views

WPF MVVM How to re-center application window after view changes?

I'm working on a very simple application using native WPF and MVVM. The main "shell" view uses what I believe is a common basic pattern, in which it contains a ContentControl that is databound to the active viewmodel, which injects the view through data templates. This is an abbreviated version of...
amnesia
1

votes
1

answer
989

Views

WPF Smith Html Editor, how do I bind to this control in xaml?

I'm using Smith Html Editor and can't figure out how to bind my html to this control in the xaml. Do I have to do it in the code-behind?
mikelt21
1

votes
2

answer
612

Views

System.Windows.Input.KeyBinding doesn't check CanExecute

So I have a simple KeyBinding on an input element that executes a command to kick off some analysis. There are a few other simple input elements that, when changed, call RaiseCanExecuteChanged on the command. This propagates to the UI button, disabling it and preventing it from executing. But this C...
N Jones
1

votes
2

answer
131

Views

different ui shows in CRT and LCD monitor

I've created a simple wpf project but it has diferent showing on crt monitors and lcd monitors: CRT: LCD: as you can see the right part of CRT showings disappears even when maximized! why is it so and how to solve it? this is the xaml code of it:
abdolahS
1

votes
1

answer
179

Views

Re-using UI in WPF from a Resource

I have a several tabs on UI where on each tab I need the below: Is there a way to avoid replicating this code in XAML for each tab by specifying the above for example in the Resources only once and pointing into that resource under each tab?
Nuts
1

votes
1

answer
367

Views

wpf image source depending on object property

I have a boolean property in my class, say: private bool isFolder; public bool IsFolder{ get; set; } and I have an image in xaml: I would like that image to have one imageSource when the IsFolder is true and another one - when it's false. How can I do that? Thanks in advance.
Mike Spike
1

votes
1

answer
335

Views

Aligment of Dynamically added columns in RadGridView

I need to right align some dynamically added columns. For RadGridView I have used the following code As a ItemsSource I have bind the DataTable to the RadGridView. I don't want to align all columns to the right, only need to align some columns.
Neha
0

votes
1

answer
23

Views

Change Button background color when clicked using WPF and binding

I am trying to change to color of button when clicked. It is taking the initial color assigned but not updating when clicked. I attaching my code, let me know where I am going wrong. I tried to implement the code provided in the following post enter link description here MainWindow.xaml snippet Main...
Manoj Pathak
0

votes
0

answer
5

Views

How to set borderbrush color to each border direction on different Thickness?

i used visualbrush on borderbrush for setting different color to each border direction. on xaml, this code did work well. each border direction color is different. but on behind code, Grid grid = new Grid(); grid.Height = this.rowHeight[r] + topHeight + bottomHeight; grid.Width = this.columnWidth[c]...
Hyun
1

votes
2

answer
1.3k

Views

Unable to populate a CheckListBox with entries from a List<>

I have the following XML from where the ID is obtained and populated to the List: ff ff 53 I have created a List as follows: public List AvailableFrames; public class CheckedListItem { public int Id { get; set; } public string Name { get; set; } public bool IsChecked { get; set; } } The Xaml where I...
1

votes
1

answer
1.4k

Views

WPF Runtime xaml/form designer

I'm wondering if it is possible to launch the visual studio wpf design surface at runtime in a similar way you could the WinForms surface? Also willing to consider paid for 3rd party controls or open source projects. Ideally I want to let users design their own windows
user48408
1

votes
1

answer
2.8k

Views

Print a usercontrol to the center of an A4 page

I have a user control which I need to print. The form is just a basic filled out form. I have the controls all placed in a stackpanel which is named and the button for printing is outside the stackpanel, so the button is not printed with. You can mind all the MVVM loading, that is done sepratly. A...
Nicholas Aysen
1

votes
1

answer
1.3k

Views

WPF Button Dynamic Command

I have a WPF form set up as follows; In the code behind, lbModules is given a List as the ItemsSource, where ModuleButton is defined as follows; internal class ModuleButton { public ImageSource ModuleIcon {get; set;} public string ModuleName {get; set;} public ICommand OnClick {get; set;} } My probl...
Trent
1

votes
1

answer
278

Views

Custom Control in WPF as necessary as in Winforms?

During an interview, the company was asking about my use of custom controls in WPF. I have found with all of the power of the WPF way of creating a control (datatemplate, control template, styles,triggers etc... ) that having to write a custom control that overrides the OnRender method really hasn't...
AshbyEngineer
1

votes
2

answer
953

Views

How to stop parent control taking touch event when it contains a nested button

so I have my control which I would like to expand on touch and show my button which is nested within the data template of the control. I would then like the button to be pressable but would also like the control to collapse if touched anywhere apart from the button Initialise Control MyControl mc =...
user1
1

votes
1

answer
726

Views

Timer Countdown Time Format

I have built a countdown timer in WPF following the tutorial here: Simple COUNTDOWN With C# - WPF Here is the code snippet I'm using: void Timer_Tick(object sender, EventArgs e) { if (time > 0) { if (time
user3342256
1

votes
1

answer
921

Views

C# WPF ListBox Chat

I'm working on C# WPF Chat application. I want it to look like Skype chat, so last added item is touching the bottom of ListBox. Screenshot:
TParizek
1

votes
0

answer
25

Views

Memory Allocation Issues (possible leak) in WPF application, using Pages and TabContol

Disclaimer: I'm having huge issue with memory managment, within my application. They have poped up first in May, 2018, but thanks to various articles on MSDN and here, SO, I was able to reduce the problem, but not really fix it. After I did some reading, testing and coding, I'm comming here, because...
Vanghern
0

votes
2

answer
25

Views

Rounded edge 3D style button in WPF

I am trying to create a round edge 3D shape styled button in WPF. I want to create a button look like this image. I used above code for creating button but it will not giving expected result. look like this. Any help will be appreciated.
Nikhil VC
1

votes
1

answer
436

Views

Hi.I want to use same menu in different pages in xaml.how to do it?

I have two pages in xaml.in first page(MainWindow.xaml),i create menu.In second page i want to use menu again. Questions: How i do this?
1

votes
1

answer
1k

Views

CollectionView: Filter does not work when binding to e. g. ListBox

I have some sort of cascaded containers that contain notes, where there is one master container, that contains all notes. The notes containers are made in a tree like hierarchy that get more specific the deeper you are in tree-structure. The reason why I have only one list has to do with a very comp...
msedi
1

votes
2

answer
1.7k

Views

Validation on Radio Buttons

I'm not really sure how to word this, so here goes. I've got some radio buttons on a form in my WPF application which get validated. They're basically a required field for this form. When I start to fill in the form, both radio buttons are marked with a red border, however when I select one of the b...
Jake
1

votes
1

answer
559

Views

how to add namespace using XmlWriter in xml document

Hi I have to save this file in xfdf file in C# using XmlWriter Class; using (var fs = File.Open("D://abc.xfdf", FileMode.Create)) { try { var doc = XmlWriter.Create(fs); doc.WriteStartElement("Highlights"); foreach (var h in Highlights) { doc.WriteStartElement("Highlight"); doc.WriteElementString("I...
Jitendra singh
1

votes
1

answer
642

Views

C# WPF Window not Updating in foreach loop

in my project I need to load "projects". I am loading all this "projects" in a foreach loop. In this foreach loop, I want to show a status window with a progressbar, which gets updated everytime a new project got load. My problem now is, that the status window with the progrssbar wont update. It se...
Sinmson
1

votes
2

answer
884

Views

WPF Lost-Focus issue in same control

I have a small problem with focusing in .net/wpf. I have written a custom user control which contains a TextBox and a SearchButton. The user-control has a lost focus event, which validate the content of the textbox if the focus is leaving. But now i have the problem, if i click on my search button,...
BendEg

View additional questions