code-behind

Can I update the value of a WPF binding from the C# code behind?

99封情书 提交于 2020-12-25 01:59:49
问题 I’m learning C# and building a UI that reads and writes integers to an XML config file. The UI uses a variety of custom user controls. I have a 3 radiobutton user control that binds to a single int variable (control returns 0,1,2). The control uses an event to trigger the update. It looks at the 3 isChecked properties to determine the new int value. But I don’t know how to update the original binding value from the code behind. It's once removed so to speak because there are two binds..one in

Can I update the value of a WPF binding from the C# code behind?

牧云@^-^@ 提交于 2020-12-25 01:57:06
问题 I’m learning C# and building a UI that reads and writes integers to an XML config file. The UI uses a variety of custom user controls. I have a 3 radiobutton user control that binds to a single int variable (control returns 0,1,2). The control uses an event to trigger the update. It looks at the 3 isChecked properties to determine the new int value. But I don’t know how to update the original binding value from the code behind. It's once removed so to speak because there are two binds..one in

Get and set WPF custom attached property from code behind

旧街凉风 提交于 2020-06-12 06:19:42
问题 I generate objects of framework Rectangle class (which is sealed) and programmatically add them to Canvas. I want to add some information to that objects. Is there such a possibility? I can get and set attached properties in XAML but these is not useful for me. 回答1: You can set attached properties in code, something like this: OwningClass.SetMyAttachedProperty(textBox, true); 来源: https://stackoverflow.com/questions/35438746/get-and-set-wpf-custom-attached-property-from-code-behind

How to set window icon in code behind in wpf?

不问归期 提交于 2020-05-11 04:03:27
问题 In xaml it is : <View:BaseWindow.Icon> /VBDAdvertisement;component/Images/logoVBD.png </View:BaseWindow.Icon> I want to convert it into code behind. Thanks 回答1: Something like myWindow.Icon = new BitmapImage(new Uri("/VBDAdvertisement;component/Images/logoVBD.png")); You may need to qualify the path more though. Edit: As i thought the path should be in pack-uri format: "pack://application:,,,/VBDAdvertisement;component/Images/logoVBD.png" 回答2: Try this its absolutely working for both png as

Having trouble with some bool/string issues

纵然是瞬间 提交于 2020-04-19 18:04:12
问题 I've got some code-behind that opens like this: namespace MyNamespace { public partial class _Default : Page { public DropDownList DDL_Reporting_RunForDaily; public bool _retrievedData = false; I want to use _retrieveData in a session variable, so I'm setting it to false from the start. Now, I have a "protected void" where I want to change the value of this variable, so I'm using the line: Session["_retrievedData"] = true; Lastly, in another "public void" I want to check the value of the

Having trouble with some bool/string issues

爷,独闯天下 提交于 2020-04-19 18:02:23
问题 I've got some code-behind that opens like this: namespace MyNamespace { public partial class _Default : Page { public DropDownList DDL_Reporting_RunForDaily; public bool _retrievedData = false; I want to use _retrieveData in a session variable, so I'm setting it to false from the start. Now, I have a "protected void" where I want to change the value of this variable, so I'm using the line: Session["_retrievedData"] = true; Lastly, in another "public void" I want to check the value of the

Asp.net click event code appears in aspx page instead of code behind

淺唱寂寞╮ 提交于 2020-01-26 04:04:34
问题 When i click on a button to define its click event, it takes me to the tags of my own aspx page instead of taking me to the code behind/aspx.cs page. This happens for home page only. the other page signup.aspx works fine and does as expected. This has happened for a number of projects with me in past few months and as i am a beginner, i don't have much idea about this. But yes i have tick marked " Place code in separate file " checkbox when creating this website in VS 2010. Thanks in advance

How to check the storyboard whether this is begin or not?

▼魔方 西西 提交于 2020-01-24 17:00:06
问题 I need to know whether the Storyboard is begun or not. If it is begun, I need to stop, otherwise I no need to stop. Both begin and stop will be done in code behind. Currently I've done this: if (parameter != null && parameter is System.Windows.Media.Animation.Storyboard) { if (!(bool)value) { (parameter as System.Windows.Media.Animation.Storyboard).Begin(); return Visibility.Visible; } else { (parameter as System.Windows.Media.Animation.Storyboard).Stop(); return Visibility.Collapsed; } } I

Response.Redirect to Class that inherits from UI.Page?

寵の児 提交于 2020-01-23 13:05:39
问题 everyone, thank for your time. Well this my problem (well it's not a probleam at all), it is possible to have a class that inherits from ui.page and then instance an object of that class and do a redirect to it ? Something like this: Public sub myMethod() Dim myPage as new myClassThatInheritsFromUIPage() Response.redirect(myPage) 'Here is one of my "no-idea" line end sub I do this in my webForm (and that what I want to do in a class that inherits from ui.page): Response.BufferOutput = True