code-behind

Set Server Side OnClick() event Programmatically

怎甘沉沦 提交于 2019-12-11 09:09:08
问题 I am looking for a way to programmatically set the OnClick event handler for a TableCell object. The ASP equivalent of what I'm trying to do will look like this: <asp:TableCell OnClick="clickHandler" runat="server">Click Me!</asp:TableCell> In the above example, "clickHandler" is a server-side function defined in the .cs CodeBehind. public virtual void clickHandler(object sender, EventArgs args) {...} However, for my situation, this TableCell object needs to be created dynamically, so setting

Execute Method from Codehind using ViewModel WPF

主宰稳场 提交于 2019-12-11 08:23:21
问题 I've abandoned the MVVM midway through app development just to get this app out. I've written a method in the code behind to update the database/datagrid etc. My application navigation is using Commands to the ViewModel firing some event but never touches the code-behind except one time to initialize the class. So basically I push the button one time and it works with the default initial setting but I can't call my code-behind Update() method anymore once the view as been intialized. How can

WPF Animate width and Height with code behind (Zoom in)

匆匆过客 提交于 2019-12-11 07:51:54
问题 I am able to animate the movement of a Border: private void MoveTo(Border target, double newX, double newY) { Vector offset = VisualTreeHelper.GetOffset(target); var top = offset.Y; var left = offset.X; TranslateTransform trans = new TranslateTransform(); target.RenderTransform = trans; DoubleAnimation anim1 = new DoubleAnimation(0, newY - top, TimeSpan.FromMilliseconds(500)); DoubleAnimation anim2 = new DoubleAnimation(0, newX - left, TimeSpan.FromMilliseconds(500)); trans.BeginAnimation

Setting the PaneGroup of a RadPane in the codebehind?

自闭症网瘾萝莉.ら 提交于 2019-12-11 06:27:41
问题 I had created a pane group with rad panes in my XAML as follows : <telerik:RadSplitContainer InitialPosition="DockedBottom" telerik:RadDocking.SerializationTag="RaddySplit"> <telerik:RadPaneGroup telerik:RadDocking.SerializationTag="PaneGroup"> <telerik:RadPane Header="WW2 Adventure" telerik:RadDocking.SerializationTag="WW2"> <vws:ww2gamegrid /> </telerik:RadPane> <telerik:RadPane Header="WW1 Adventure" telerik:RadDocking.SerializationTag="WW1"> <vws:ww1gamegrid /> </telerik:RadPane> <

Assign Mahapps.Metro:IconPacks to button in code behind

匆匆过客 提交于 2019-12-11 04:57:00
问题 I am trying to assign an icon from any Mahapps.Metro.IconPacks to an rectangle respectively to a button with text. How do I do this if I want to use the new IconPacks? Effectively I need to convert an Mahapps.Metro.IconPacks.PackIconModernKind to VisualBrush or canvas or actually anything I can use to place it in a button. Any help is appreciated! Thanks 回答1: You can place any IconPack Control directly to the content of the Button or to a container like a Grid . The Xaml way <Button Content=

How can i refresh a asp page from code behind? C# [duplicate]

折月煮酒 提交于 2019-12-11 04:22:42
问题 This question already has answers here : Refresh Page C# ASP.NET (10 answers) Closed 4 years ago . I'm kind of new at this and my English is also poor. Anyway: I'm trying to set a Timer that refreshes my page if there is any new record on my report. Apparently my timer works fine because when i debugged it it enters into the function Timer1_Tick , but it doesn't refresh my Page. Here is the code: System.Timers.Timer Timer1 = new System.Timers.Timer(); Timer1.Interval = 10000; Timer1.Elapsed +

In WPF code-behind, how do I set the background color for each individual ListBoxItem where the color is based on the item itself?

故事扮演 提交于 2019-12-11 04:09:22
问题 My end goal is to have a ListBox show me a list of colors, where the value of the background color is the color itself. Eventually, this ListBox will load a previously saved collection of colors, but for now I'm just trying to get it to work with dummy data - a dictionary I filled up using the colors from System.Windows.Media.Colors ( <string, Color> , where string is the friendly name and Color is a custom class that only contains the Red , Green , Blue , and Hex values for the color). It's

Base Page or Base Master Page or Nested Masters?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 03:48:34
问题 I've got a site with two master pages: one for one-column layout and one for two-column layout. These are nested within a master page that provides a common header and footer. I have functionality that I want each of the content pages to have; should I: create a page base class and inherit that inside my content pages, or create a master page base class and inherit that inside one of my levels of nested master page? Ultimately I want the content pages to have access to a connection object and

MVVM - calling UI-logic in code behind from ViewModel

*爱你&永不变心* 提交于 2019-12-10 20:02:22
问题 I'm working on some .Net XAML application using MVVM pattern. According to MVVM I keep my app logic in VM and in Code Behind I do UI-related actions. But I need to execute some UI-related code in Code Behind in respond to some logic in VM. Example: I need to show an error message (custom toast notification in my case) when login operation failed. Login operation resides in VM, but I can't use any UI-specific classes in my VM, so I made an event in VM and hooking up to in in Code Behind, doing

Deploy asp.net application without compiling DLL

房东的猫 提交于 2019-12-10 17:56:35
问题 When I publish any type of asp.net application, my code is precompiled into various assemblies. I would like to avoid this so that I can upload an aspx page and its corresponding codebehind file. I understand the benefits of doing it either way, but what is desired here is the least risky way to publish changes. How does one properly deploy an asp.net project without compiling assemblies? Is the process different for each model (web app, MVC..) 回答1: Sounds like you have a Web Application