Refresh a label on WPF page [closed] - wpf

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How do I refresh a label on WPF page.
Basically the label displays how many agents there are, so when I put all the users details in and click Create User. When I click the button, I need the label to refresh on that page.
I have tried setting the content to null and then reloading the data.
int NumberOfAgents = _Users.Where(w => w.RoleID == _Role.FirstOrDefault(a => a.RoleType == "Agent").RoleID).ToList().Count();
lblCountAgent.Content=null
lblCountAgents.Content = NumberOfAgents.ToString();
But this does not seem to work.
If anyone could help me out on this that would be great.

Your code seems ok, NumberOfAgents probably isn't what you think it is and should be checked in the debugger.
On a side note, please don't code this way in WPF. You shouldn't be programmatically setting properties like "Content", and most of the time you shouldn't be programmatically setting properties at all.
Instead, the "Content" property of your label should be bound to a "NumberOfAgents" property in a ViewModel class that can then be set (raising PropertyChanged) when you create a user. This will propagate through the UI via the binding system. Here is an MSDN tutorial on how to set up MVVM with WPF.

Related

how is useful to use IsAsync in the binding of a combobox? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 months ago.
Improve this question
When I set the items source of a combobox, I have the option to se IsAsync as true.
When is it useful to use this parameter?
Thanks.
IsAsync is most useful for properties whose values take take a long time to retrieve or set via binding. It can make your application remain responsive while the bound value is being retrieved/set. For values that are retrieved immediately, it is not at all useful.
Does your checkbox-bound value take a long time to retrieve/set its values? If not, then IsAsync is a waste.
I will admit I've never used IsAsync with a two-way binding. Usually I save it for read-only properties

How can i group xaml styles into a tree structure for easy selection? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have several styles in one file. When am to apply a particular style to a control, i have to scroll through several names to get to the one of my choice.
Am currently using vs 2017.
If am to apply a custom style, i select the control, click on style in the properties panel, i then select local resource which in turn displays a long list of my custom styles in the several files of my resources.
How can i group the styles , for example texblock styles , text box styles, such that have to look through the long list?
Unfortunately, you can't get that type of grouping in these lists. They simply list all available resources.

Wpf custom control for cinema, stadium or hall [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've got a task to create in wpf control as close as possible to this one
from the link (please click "Select Tickets" tab to see a control)
I'd like to ask for any advise where to start from?
Should I use canvas? If It's not a canvas, How to use zoom?
There are many answers for this question. At first sight, I would try to follow the next steps :
Create a control for the dots -> A circle (Path) which has a dependency property for its color.
Create a dynamic Grid with the number of columns and rows that you want and insert in every cell the control that you`ve created in the first step with the right fill color.
The zoom should be achieved by adjusting the number of columns and rows in your dynamic grid.If the number of columns it is reduced, the custom control will be stretched and will appear as a zoomed region.
Keep in mind that you have to use ObservableCollections and TwoWay Bindings in order to get the updates on the UI.
Hope it helps! Good luck
You can use a ViewBox to enable the control to size to the available space.
#Dragosh's answer is a good option. But there are often seating layouts that are not a grid. I would recommend creating a custom ItemsControl that binds to a collection of 'Seats' that have properties outlining their Section, Row, etc. and location. That way you can create a DataTemplate and ItemStyle that places the seat control at the correct location.

basic search bar using VB.Net [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I actually don't know how to make a search bar. Can someone give me instructions of creating one? And how will it be displayed if i generate the search bar.
I would like to use a textbox and a button for this search bar. It's like, when you input a data on the textbox and click the button, it will go in a new form wherein the result from the inputted keyword will be displayed. The data is coming from the database I have. The database consist of list of students, and the keywords you need to type on the search bar is their student_ID or their names.
Thank you to those who will respond!
I'm not sure if what you want is a database of past websites that get suggested from the textbox..... If so just click on the textbox and turn the auto-completion mode to suggest and auto complete source to allurl.
If you want the button to go to the website that is in the textbox then the code for the button is (name of webbrowser).navigate(name of textbox).text
If this is not what you want just tell me what it is I have some experience with web browsing in vb.net

In MVVM should the setter of a property contains other methods or logic? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
In MVVM design pattern, of the properties that are binded to the view, should they only have "dumb" setters that updates an internal value?
Or is it ok to have other methods or logic within it that updates other parts of the viewmodel?
If that is the case, should any action from the screen be routed through an action only?
For example:
I have a toggle button in which its "IsChecked" property is binded to a property in my viewmodels.
Should I handle the action separately than the property changed by creating a command, or can I used the setter of the "IsChecked" property to handle custom logic?

Resources