binding

WP8.1 C# Binding Contact Image

孤者浪人 提交于 2019-12-30 07:43:14
问题 Information Quite simply, I’m attempting to create an app that would display the contacts for a user. I’m also a self-taught programmer, so I have experience with programming in some aspects, but I am relatively new to data-binding in general. To begin, I have a ListView control that has an image binding within it. <ListView x:Name="ContactsView" ItemsSource="{Binding}"> <ListView.ItemTemplate> <DataTemplate> <Image x:Name="ContactImage" Source="{Binding Converter={StaticResource

Custom DataGrid column with a CellTemplate and binding

北慕城南 提交于 2019-12-30 07:04:10
问题 I need to create a reusable DataGrid column with a custom CellTemplate. This CellTemplate should, among other things, contain a TextBlock control to which I need to bind values to display in the DataGrid. All examples I've seen so far specified the CellTemplate for a column directly when using it in a DataGrid's Columns property and also specified a Binding directly to the TextBlock, e.g.: <data:DataGrid> <data:DataGrid.Columns> <data:DataGridTemplateColumn Header="Name"> <data

Replace Entire ObservableCollection with another ObservableCollection

最后都变了- 提交于 2019-12-30 06:27:26
问题 public class Alpha { public ObservableCollection<Beta> Items { get; set; } public Alpha() { Items = new ObservableCollection<Beta>(); } public void DoSomething() { Items = GetNewItems(); // whenever I do this, Items gets a new referene, // so every WPF binding (e.g. datagrids) are broken } public ObservableCollection<Beta> GetNewItems() { var ret = new ObservableCollection<Beta>(); // some logic for getting some items from somewhere, and populating ret return ret; } } How can I replace the

WPF ListView Binding ItemsSource in XAML

前提是你 提交于 2019-12-30 05:55:32
问题 I have a simple XAML page with a ListView on it defined like this <ListView Margin="10" Name="lvUsers" ItemsSource="{Binding People}"> <ListView.View> <GridView> <GridViewColumn Header="Name" Width="120" DisplayMemberBinding="{Binding Name}" /> <GridViewColumn Header="Age" Width="50" DisplayMemberBinding="{Binding Age}" /> <GridViewColumn Header="Mail" Width="150" DisplayMemberBinding="{Binding Mail}" /> </GridView> </ListView.View> </ListView> In the code behind I do:- public

WPF DataTrigger on any data (binding) change

早过忘川 提交于 2019-12-30 05:25:27
问题 I want to begin a storyboard, every time my Image source changes. I have implemented INotifyPropertyChanged. Can anyone help me achieve this? Thanks, <Image Name="pic" HorizontalAlignment="Center" VerticalAlignment="Center" Source="{Binding ElementName=uc, Path=Image}"> <Image.Resources> <Storyboard x:Key="picStory" x:Name="picStory"> <DoubleAnimation Storyboard.TargetProperty="(Image.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)" From="0" To="20" Duration="0:0:0.7" />

WPF: Showing and hiding items in an ItemsControl with effects

穿精又带淫゛_ 提交于 2019-12-30 04:44:11
问题 I've been using this great article as a basis for showing and hiding elements with a transition effect. It works very neatly in that it lets you bind the Visibility property just as normal, then define what happens when the visibility changes (e.g. animate its opacity or trigger a storyboard). When you hide an element, it uses value coercion to keep it visible until the transition is finished. I'm looking for a similar solution to use with an ItemsControl and an ObservableCollection . In

Set the binding value directly

你离开我真会死。 提交于 2019-12-30 04:40:13
问题 Is it possible to set the value behind a two-way binding directly, without knowing the bound property? I have an attached property that is bound to a property like this: <Element my:Utils.MyProperty="{Binding Something}" /> Now I want to change the value that is effectively stored in Something from the perspective of the attached property. So I cannot access the bound property directly, but only have references to the DependencyObject (i.e. the Element instance) and the DependencyProperty

BindingExpression path error: property not found on 'object'

旧街凉风 提交于 2019-12-30 03:15:11
问题 I've been searching for hours on this error that appears in the output window. I'm pretty new to bindings in WPF, so I'm sure there's something I'm missing. Full text of the error (there is one for each binding path, all similar to this one): System.Windows.Data Error: 39 : BindingExpression path error: 'TestItem' property not found on 'object' ''String' (HashCode=-842352750)'. BindingExpression:Path=TestItem; DataItem='String' (HashCode=-842352750); target element is 'TextBlock' (Name='');

WPF Trigger binding to MVVM property

二次信任 提交于 2019-12-30 03:15:10
问题 I have a datatemplate containing an image that I want to be hidden if the the value of a property in a ViewModel is true. Can anyone tell me why the the xaml below does not work? <Image x:Name="img" Source="..\Images\List_16.png" Margin="0,0,5,0"> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding CurrentListHasPendingChanges}" Value="True"> <Setter Property="Image.Visibility" Value="Hidden" /> </DataTrigger> <DataTrigger Binding="{Binding CurrentListHasPendingChanges}"

How do you concatenate text when using Bind expression in asp.net

十年热恋 提交于 2019-12-30 02:53:05
问题 What is the syntax to concatenate text into a binding expression for an asp.net webpage (aspx). For example if I had a hyperlink that was being bound like this: <asp:HyperLink id="lnkID" NavigateUrl='<%# Bind("Link") %>' Target="_blank" Text="View" runat="server"/> How do you change, say, the Text to concatenate a bound value with a string? Variations like this aren't quite right. Text='<%# Bind("ID") + " View" %>' neither does Text='<%# String.Concat(Bind("ID"), " View") %>' 回答1: Use Eval