Questions tagged [wpf]

63411 questions
0

votes
0

answer
20

Views

Some Special characters doesn't appear in WPF

In my application I use a shower barcode to scan DataMatrix in GS1 format. The code looks like this: ]d2240ARD567910921111706292150026590100923957 However, there are special characters hidden between some visible characters. When I scan my DataMatrix in the windows search bar, they appear. Except t...
Eros Guil
1

votes
2

answer
1.5k

Views

WPF Material Design Raised Button Hovered state

I'm trying to recreate a material design look & feel for a button. For the focused (hovered) state the guidelines say to make a 12 % #000000 shade over the button. I was wondering how this could be achieved in WPF. I've been looking around a good option would be to add a non-hittable rectangle over...
Bart Pinnock
1

votes
1

answer
186

Views

Remove items from ObservableConcurrentCollection [closed]

I have a DataGrid with ItemsSource bound in XAML to an ObservableConcurrentCollection property. This allows me to update the collection from a worker thread, and have the changes automatically reflected in my DataGrid. The problem is that I can only add items to that collection. I need to be able...
iMezouar
0

votes
0

answer
6

Views

Microsoft WPF tutorial - Create the UI for ExpenseReportPage doesn't do what it's supposed to

I am learning WPF from (https://docs.microsoft.com/en-us/dotnet/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application), but when i come to section (https://docs.microsoft.com/en-us/dotnet/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application#create-the-ui-fo...
Janko
1

votes
1

answer
84

Views

Odd behaviour onCanExecute RelayCommand MVVMLight 5+

I'm migrating a tool from MVVM Light 4.0.3 to 5.4.1 and I have found a very odd issue with the newest RelayCommand implementation. This is the old implementation in the V4.0.3: This is the newest implementation in the V5.4.1: Before I was able to use variables to define the canExecute behaviour (ena...
1

votes
2

answer
131

Views

Dynamic DataTemplate in a PowerShell WPF app

I have created a simple WPF application using XAML and PowerShell, consisting of a TabControl in whose child TabItems I wish to display multiple kinds of data. Depending on the type of data provided, I want the TabControl's child TabItems to use a different DataTemplate. I understand that the best...
Spencer
0

votes
1

answer
13

Views

C# WPF Menu not displaying first “_” in header

I am trying to dynamically populate the headers of MenuItems based on filenames the MenuItem will open when clicked. I've found that whenever a header name has one or more '_''s the first one is never displayed. I'm trying to determine the best workaround for this problem. I could replace the first...
Evan Miller
1

votes
2

answer
59

Views

DatePicker default date in other format

I have a WPF window with a DatePicket controller. I would like to show the current date not the 'Show Calendar' text. I used this reference xmlns:sys='clr-namespace:System;assembly=mscorlib' and this code It works fine but I would like to change the date format like this: yyyy. mm. dd. How can I do...
alratar
1

votes
4

answer
44

Views

DataGridHyperlinkColumn text color when highlighted

I have a simple WPF application which displays reddit links in a DataGrid: Notice however that the link in the DataGridHyperlinkColumn isn't visible when a row is selected, due to the color of the link and the color of the row highlight. What's a good way to resolve this? Change the link text color?...
dharmatech
1

votes
1

answer
37

Views

Text Content only via button

I am trying to get the following: inside my page I have a textbox and button. When the user presses 'Enter' on the keyboard it should do the same as clicking the button. my code looks roughly as follows: Inside ViewModel: public Page1VM() { Btn_ConfirmCommand = new RelayCommand(Btn_ConfirmMethod); }...
Codey
1

votes
2

answer
60

Views

Expander expands only after file is loaded

Image : I want my expander to expand only after a file is loaded. Please help me how to do that. I am using command to the load button.
Vijay Bhargav G
1

votes
1

answer
43

Views

RX: How to bind an IObservable<object> to a property (ReactiveUI)

I have class MyClient with an IObservable (Client.StatusStream()). Now I would like to combine ReactiveX and ReactiveUI. But the documentation is not providing any example how to use them together. I have tried some extension methods so far (f.e. .ToProperty), but they are not working. public partia...
Dominic Jonas
1

votes
2

answer
57

Views

Is there a way to automatically create CRUD for EF Model (DB First currently)

I am creating a WPF app and I have an existing DB that I would like to use and NOT recreate. I will if I have to, but I would rather not. The DB Is sqlite and when I add it to my data later and create a DataModel based on the DB, I get the model and the DB Context, however there are no methods creat...
Charlie
1

votes
3

answer
2.4k

Views

RibbonGroupsPanel … accepts only IProvideStarLayoutInfo instances?

I am trying to use a RibbonGallery in my application, but I get this error at runtime, when the tab which contains the gallery is loaded: 'RibbonGroupsPanel RegisterStarLayoutProvider and UnregisterStarLayoutProvider accepts only IProvideStarLayoutInfo instances. Parameter name: starLayoutInfoProvi...
melculetz
3

votes
0

answer
47

Views

How can I detect a hidden Desktop?

There are a lot of shortcuts defined by Windows (see here), including the combination WIN+D to 'Display and hide the Desktop'. I am working on an application developed with C# and WPF and I have to react on hiding the Desktop, e.g. the user pressed WIN+D. I tried several approaches so far. First, I...
Endgegner85
0

votes
1

answer
26

Views

Binding a bool to button visibility

I have followed both examples in this question however I am unable to bind a boolean in my view model to a button in my view. I am using a different button that toggles whether or not the other button should be visible or not, can anyone see what is wrong? Currently I am trying to bind the boolean t...
je42
2

votes
0

answer
18

Views

How to notify Properties outside of an Object instance?

I am a WPF beginner and I have an issue with the PropertyChanged Events: I have a viewmodel that contains an instance of another viewmodel. (I will use general names here) I want the instance of the AxisVM to notify my SomeDouble property. (Can´t use a converter) edit: I didn´t include the full cl...
d0neall
1

votes
1

answer
1.1k

Views

Handling a click event on the whole UserControl surface

I am using a TreeView in a MVVM scenario. As the display and context menu of children TreeViewItem depends on the type of view-model, I am using data-templates to select the right UserControl to display (much easier to manage than StyleSelector). My problem is that I need to handle commands when the...
Ucodia
0

votes
2

answer
12

Views

Do not understand behavior of wpf updating dynamically created image control visibility changing every seconds

I have a Grid with 8 rows and 8 columns in wpf: the code behind is: public partial class MainWindow : Window { private const int MaxRow = 8; private const int MaxCol = 8; public MainWindow() { InitializeComponent(); DataContext = this; } private void Start() { for (int i = 0; i < MaxRow ; i++) { for...
Edgar
1

votes
2

answer
2k

Views

Binding ObservableCollection of ObservableCollections to nested ListView in TabControl TabItems

Rather than declaring a tab for each of the ObservableCollections explicitly as in the first TabControl below I need them to generate dynamically as in the second TabControl and have the ItemsSource of the nested ListView set to each of the nested ObservableCollections. In other words: Why aren't th...
Dan
1

votes
2

answer
189

Views

ComboBoxItem background rainbowRGB color

Folks: I want to set the background color of a ComboBoxItem to be RainbowRGB: and this is my current xaml code. I prefer to do it in xaml code: Anyone can give some pointers? Thanks.
Ono
1

votes
1

answer
3.6k

Views

How do I achieve multi selection in a combobox in WPF

I am new to WPF, I am looking for a dropdown with checkbox to select multiple values. The source to the drop down would be from a list (list).
user1721890
3

votes
1

answer
162

Views

Clear RichTextBox text through UI Automation?

In C# or VB.NET, I would like to clear the entire text of a read-only RichTextBox control that reside in a external WPF application. The control supports text pattern, but not value pattern. The goal is to prevent this control from appending thousands of new text lines, because at the end I noticed...
ElektroStudios
0

votes
0

answer
7

Views

Windows sleep even for UWP apps

In my app I have UP and DOWN channels which continuously listen for Audio stream. I want to know that In windows is there any event which will tell me that machine is now going to sleep state (not sign-out because machine will go to sleep after sign-out based on the user settings) so that i can susp...
Pavan Tiwari
1

votes
1

answer
875

Views

why WPF combobox itemssource converter gets whole collection and not items?

When I debug with following implementation. The Convert-method parameter value has all values and naturally the cast fails. XAML VIEWMODEL public enum CustomerIdentifier { ClientPointNo = 0, ClientNo = 1, MeterNo = 2, CustPointNo = 3 } public ObservableCollection CustomerSearchNumbers { get; private...
char m
1

votes
2

answer
1.5k

Views

The calling Thread cannot access this object because a different thread owns it. Exception

private void Thread1_Exe() { try { int sleepValT1 = Convert.ToInt32(listBoxT2.SelectedValue); int StartLoop = 0; int EndLoop = 10000; for (int i = StartLoop; i listboxE1.Items.Add('T1: Execution Count> ' + i.ToString()))); Thread.Sleep(sleepValT1); } } catch (Exception Ex) { MessageBox.Show(Ex.Mess...
Zafeer Ul Haq
1

votes
1

answer
196

Views

Set Carret Position in RichTextBox C# WPF

I have a RichTextBox with Name = Editor! And the following code : String textRich = new TextRange(Editor.Document.ContentStart, Editor.Document.ContentEnd).Text; EditorColor ec = new EditorColor(textRich);//Transform The text in RTF Text Stream stream = new MemoryStream(ASCIIEncoding.Defa...
Vasiu Alexandru
0

votes
0

answer
4

Views

Unable to set Binding of a UserControl element in WPF

I'm working on a WPF application and I don't want to copy/paste code. I want reusable elements like in React/JavaScript. In this particular case I have a DataGrid that I want to use in different locations of my application with different bindings/variables. I don't want to copy/paste the DataGrid-XA...
reinoslav
1

votes
1

answer
1.5k

Views

Reading an Xbox controller in a WPF application

Is it possible to read an Xbox One controller in a WPF application? I'm connecting it through a USB cable. I'd like to get boolean values from buttons and be able to read analog values from sticks and triggers. I will be using those values to control a Pololu 3pi robot. Is there a simple way to achi...
Nollie
1

votes
1

answer
773

Views

Load image from specific file

How can I set the ImageSource to be an image from a specific folder? I tried moving the image in Debug and running the following code: image.Source = new BitmapImage(new Uri('kafpodhlato.png')); But I get the following error: An unhandled exception of type 'System.UriFormatException' occurred in Sys...
ThP
1

votes
0

answer
11

Views

How to change logic of autoupdater?

So I came up with the following There are two projects in Solution (the updater and the program itself) the updater runs, verifies the version on the server if there is a new version downloads the archive with the files of the new program 3.Unzip it to the program folder, launch the main application...
Sneikof
1

votes
2

answer
59

Views

Unhandled exception occurs after handling exception

This theme from my preveus question: How to remove and create log in Windows Event Viewer I created wpf app. I'm catching Unhandled exception with 3 ways: public partial class App : Application { public App() { DispatcherUnhandledException += App_DispatcherUnhandledException; Dispatcher.UnhandledExc...
DIlshod
1

votes
4

answer
74

Views

How to format WPF timer to HH:MM:SS

Im working on a program that displays time from when you clicked a button. The issue is that the time is displayed as just '1', '2', '3' etc.. when I would like it to be displayed as '00:00:01', '00:00:02' This is in WPF. I have searched all over to find people saying you use increment.ToString('hh...
IBeDubya
1

votes
1

answer
81

Views

Caliburn micro action on model-object

Using caliburn micro you can execute a method by doing this: and in theViewModel have a method like this: public void ClickMe() { //Method will be execute upon button click } Is it possible to bind this to a method inside a property in the ViewModel? Like this?:
1

votes
3

answer
39

Views

IsEnabled property cannot be binded to a DependencyProperty and IValueConverter

I have the following code: XAML code: C# Code /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public static readonly DependencyProperty SectionTitleProperty = DependencyProperty.Register(nameof(SectionTitle...
Graviton
1

votes
3

answer
61

Views

How can I properly execute an asynchronous method from a ViewModel?

For the purposes of this question, I've got a simple Window with the following XAML: Check Whenever the users enters text in the TextBox or checks the CheckBox, I'd like to perform a slow task (such as saving my model's state to disk). Here's the view model: public class ViewModel : ViewModelBase /...
redcurry
1

votes
2

answer
77

Views

Correctly implementing Tasks in a WPF application

I'm looking for some advice on getting to grips with Tasks in WPF and was wondering if anyone could have a look over my code and point out what I'm doing incorrectly? Basically the application takes a postcode from the UI which is used to instantiate a Task service which will get Longitude/Latitude...
Luke Dee
1

votes
3

answer
62

Views

Creating (N) directories in a specific path in a loop stopping abruptly

I am attempting to create 10,000 folders in a specific directory. I have an algorithm for creating a random names for each folder. The issue I am having is when I run this code, It stops with creating about 21 directories. The MessageBox.Show() is debug, however, it never pops up. this.WorkingDir i...
Reap
1

votes
2

answer
51

Views

WPF Localization of dynamic string in TextBlock

I'm currently working on a .NET Framework 4.7.1 WPF application. I need to localize a string in a TextBlock element, using standard .resx files. The problem is, in my TextBlock, I use a dynamic resource, consisting out of a text and an increasing number (counter). Do you know how to localize this te...
accordo777
1

votes
2

answer
109

Views

Want textbox to empty when data is entered

Using C# and WPF. I have a lot of textboxes that are data bound like this: Text='{Binding ZipCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}' I need an event handler that will set ZipCode to '' when the user clicks or tabs into the box to enter data. The code posted works, but I need it to b...
Buck

View additional questions