binding

SwiftUI @Binding update doesn't refresh view

有些话、适合烂在心里 提交于 2021-02-18 10:14:28
问题 I feel like I'm missing something very basic, but this example SwiftUI code will not modify the view (despite the Binding updating) when the button is clicked Tutorials I have read suggest this is the correct way to use a binding and the view should refresh automatically import SwiftUI struct ContentView: View { @Binding var isSelected: Bool var body: some View { Button(action: { self.isSelected.toggle() }) { Text(isSelected ? "Selected" : "Not Selected") } } } struct ContentView_Previews:

Binding ViewModel to multiple windows

倖福魔咒の 提交于 2021-02-18 05:47:05
问题 I'm re-writing my windows forms project that does scoring for sheep shearing events (don't ask, its a huge sport in New Zealand) from vbnet to wpf c# and have struck a problem that I can't seem to overcome. I have two windows. One is the source window where you type things in (like the current event name), and the other window will display this information in a flash way for projection onto a screen (so will be on a second monitor) along with some other data coming in via XML over the network

bind_result() - Number of variables doesn't match number of fields

不想你离开。 提交于 2021-02-17 03:35:31
问题 Code: // get value of id that sent from address bar $id=filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); if ($id === false) { //filter failed die('id not a number'); } if ($id === null) { //variable was not set die('id not set'); } //white list table $safe_tbl_name = ''; switch($tbl_name){ case 'Table1': $safe_tbl_name = 'MyTable1'; break; case 'Table2': $safe_tbl_name = 'MyTable2'; break; default: $safe_tbl_name = 'forum_questions'; }; $sql="SELECT * FROM `$safe_tbl_name` WHERE id=?"; if

INotifyPropertyChange confusion

烈酒焚心 提交于 2021-02-10 19:38:21
问题 I am converting a VB.NET Winforms project to C# WPF. I have a project with two WPF windows and a ViewModel as a referenced project. public class SheepViewModel : INotifyPropertyChanged { private string _CurrentEventName; public string CurrentEventName { get { return _CurrentEventName; } set { _CurrentEventName = value; OnPropertyChanged("CurrentEventName"); } } static SheepViewModel _details; public static SheepViewModel GetDetails() { if (_details == null) _details = new SheepViewModel();

Binding textbox in ListView's header datatemplate to a filter property

喜你入骨 提交于 2021-02-10 18:53:54
问题 I am creating a customized listview header that has the header text but also has a textbox that you can enter to filter the content of that column. My code currently looks like this: <UserControl.Resources> <DataTemplate x:Key="myHeaderTemplate"> <StackPanel> <TextBlock FontSize="14" Foreground="DarkBlue" Margin="20,4" Text="{Binding}" /> <TextBox Text="" Margin="4,2" /> </StackPanel> </DataTemplate> </UserControl.Resources> which is the definition for the header datatemplate containing the

Binding textbox in ListView's header datatemplate to a filter property

末鹿安然 提交于 2021-02-10 18:53:24
问题 I am creating a customized listview header that has the header text but also has a textbox that you can enter to filter the content of that column. My code currently looks like this: <UserControl.Resources> <DataTemplate x:Key="myHeaderTemplate"> <StackPanel> <TextBlock FontSize="14" Foreground="DarkBlue" Margin="20,4" Text="{Binding}" /> <TextBox Text="" Margin="4,2" /> </StackPanel> </DataTemplate> </UserControl.Resources> which is the definition for the header datatemplate containing the

Binding with dictionary item by key

邮差的信 提交于 2021-02-09 09:28:11
问题 Let's say I have some dictionary and I want to bind items from this dictionary to some controls and I want to bind by item key. public partial class Window1 : Window { public Window1() { InitializeComponent(); Dictionary<string,string> dictionary = new Dictionary<string,bool>(); dictionary.Add("Item 1", "one"); dictionary.Add("Item 2", "two"); dictionary.Add("Item 3", "three"); // ... dictionary.Add("Item 99", "ninety nine"); // ... this.DataContext = //... } } XAML: <Window ... > <Grid>

Binding doesn't work on DependencyObject created in XAML

纵然是瞬间 提交于 2021-02-08 20:37:57
问题 I'm trying to pass multiple CommandParameters in XAML with the use of a custom class. I have created a class called ValueCommandArgs that inherits from DependencyObject and has two DepencyProperties (lets call them Value1 and Value2 for this example). The button which is supposed to call a command and pass this object looks like this: <Button Command="{Binding ChangeValueCommand}" Content="Execute Command"> <Button.CommandParameter> <args:ValueCommandArgs Value1="{Binding TestValue1}" Value2=

Binding doesn't work on DependencyObject created in XAML

牧云@^-^@ 提交于 2021-02-08 20:37:15
问题 I'm trying to pass multiple CommandParameters in XAML with the use of a custom class. I have created a class called ValueCommandArgs that inherits from DependencyObject and has two DepencyProperties (lets call them Value1 and Value2 for this example). The button which is supposed to call a command and pass this object looks like this: <Button Command="{Binding ChangeValueCommand}" Content="Execute Command"> <Button.CommandParameter> <args:ValueCommandArgs Value1="{Binding TestValue1}" Value2=

Binding doesn't work on DependencyObject created in XAML

≡放荡痞女 提交于 2021-02-08 20:36:54
问题 I'm trying to pass multiple CommandParameters in XAML with the use of a custom class. I have created a class called ValueCommandArgs that inherits from DependencyObject and has two DepencyProperties (lets call them Value1 and Value2 for this example). The button which is supposed to call a command and pass this object looks like this: <Button Command="{Binding ChangeValueCommand}" Content="Execute Command"> <Button.CommandParameter> <args:ValueCommandArgs Value1="{Binding TestValue1}" Value2=