binding

How does WPF sets a list item value?

爱⌒轻易说出口 提交于 2019-12-12 03:31:07
问题 I have a WPF application (MVVM pattern) with databinding to strings and list of strings: public string Property { get { return _model.property; } set { if (value == _model.property) { return; } _model.property= value; base.NotifyPropertyChanged(); } } public List<string> PropertyList { get { return _model.PropertyList; } set { if (value == _model.PropertyList) { return; } _model.PropertyList= value; base.NotifyPropertyChanged(); } } My binding looks like this: <TextBox Text="{Binding Path

Bind Textbox Text to a Static Property

有些话、适合烂在心里 提交于 2019-12-12 03:22:36
问题 I have a Static Class with the following Static Property: public static class PrintingMethods { public static String DocsCountString { get { return printDocuments.Count.ToString(); } }} I have a text box that I bind to this property: <TextBlock Text="{x:Static my:PrintingMethods.DocsCountString}" x:Name="PagesNumber"/> This works - I can see the number in the Text, But it never changes If the Property Value Change. I am quite new to this, I know there are things like Dependency Object and

How to fill a ComboBox with values from a list, and bind the selected item to a string in another ViewModel

天涯浪子 提交于 2019-12-12 03:17:30
问题 TL;DR at bottom A little back story for context. I'm creating an xml tool that will enable folks to input data needed for a game we're making without having to worry about hand-jobbing XML directly. The tool will output various XML files to be used by the game engine (for example, complex NPC Dialogue nodes with references to scripts to run when a given piece of dialogue is used... basically all the data to feed the game engine). I'm stuck trying to figure out a perplexing issue I'm having...

UserControl's Resources as UserControl's DataContext?

房东的猫 提交于 2019-12-12 03:14:42
问题 Is it possible to give UserControl's Resources(Or one of its resource) as UserControl's DataContext? I tried to bind a Button's Command Property in a DataGrid's CellTemplate to a property in my ViewModel. If it were use a ListBox instead of DataGrid this works for me such as below, <ListBox.ItemTemplate> <DataTemplate> <HyperlinkButton Content="{Binding DESCRIPTION}" Command="{Binding DataContext.SelectSingleBackCommand, ElementName=LayoutRoot}"/> </StackPanel> </DataTemplate> </ListBox

DevExpress WPF grid bound to List<String> using MVVM

和自甴很熟 提交于 2019-12-12 03:08:03
问题 I am trying to do something that should be simple, but think I am just not seeing the answer. I have a List with several strings. I would like to bind it to a DevExpress DXGrid. It appears that the grid is showing the correct number of row, but not displaying my text. I am using the MVVm patern and have seperated my ViewModel and View. Thanks for the help. Here is the XAML code: <dxg:GridControl Grid.Row="0" DataSource="{Binding Path=ErrorLog}" > <dxg:GridControl.Columns> <dxg:GridColumn

Android: manipulate a variable's value inside Service methods and get from different Activities

梦想与她 提交于 2019-12-12 03:07:48
问题 I implemented Service for listening user location: public class ListenLocationService extends Service { private final IBinder mBinder = new LocalBinder(); public interface ILocationService { public void StartListenLocation(); public Location getUserLocation(); } public class LocalBinder extends Binder implements ILocationService{ LocationManager locationManager; LocationListener locationListener; Location userLocation = null; public void StartListenLocation() { locationManager =

Binding vs MultiBinding => Different results

ぐ巨炮叔叔 提交于 2019-12-12 03:05:01
问题 I have a TextBlock inside a StackPanel . Since I'm using TextTrimming , I have to set manully the TextBox 's width according the StackPanel.ActualWidth . <StackPanel HorizontalAlignment="Stretch"> <TextBlock HorizontalAlignment="Left"> <TextBlock.Width> <MultiBinding Converter="{StaticResource WidthConverter}"> <MultiBinding.Bindings> <Binding RelativeSource="{RelativeSource Self}" /> <Binding RelativeSource="{x:Static RelativeSource.Self}" Path="TemplatedParent.Parent.ActualWidth" /> <

Binding a DataGridView to multiple Tables in DataViewManager or DataSet

陌路散爱 提交于 2019-12-12 02:58:51
问题 I have created three data tables by pulling data from an sql database. DT1, DT2, DT3. I have added these three tables to a data set, myDS. I have added relations between these three tables. I then dragged a DataGridView onto my form and I want to bind the three tables to the DataGridview. So I added my dataset DS to a dataview manager, myDVM. I bound myDVM to a bindingsource, bindingSource1, and made it the data source for the DataGridView. I am not sure how to bind the tables I want from

Closure or Bind

穿精又带淫゛_ 提交于 2019-12-12 02:56:26
问题 Is there any difference between limiter 1 and limiter 2? var limiter1 = function(limiter){ return function(item){ return item > limiter; }; }; var limiter2 = function(limiter){ return function(limiter,item){ return item > limiter; }.bind(this,limiter); }; 回答1: In most cases, they will function identically. However... If you ever start to actually use the value of this , the function returned by limiter1 will be unbound (so a consumer could change the value with a call to Function.prototype

Can't access datacontext of parent

淺唱寂寞╮ 提交于 2019-12-12 02:56:08
问题 Basically what i have is a ListBox with ContextMenu <ListBox Margin="2,0,0,0" Grid.Row="1" ItemsSource="{Binding MyCollection}"> <ListBox.ItemTemplate> <DataTemplate> <Button Style="{StaticResource NoVisualButton }" Tag="{Binding ID}" Width="430" toolkit:TiltEffect.IsTiltEnabled="True" Margin="0,0,0,12" Click="OnSelectWorkOutItemClick"> <StackPanel> <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenu> <toolkit:MenuItem Header="delete" Tag="{Binding ID}" Click=