data-binding

WPF Binding Collection with Index

百般思念 提交于 2021-02-04 22:12:13
问题 I'm trying to use a collection that is a property of another collection to bind to a listbox. The following works fine <ListBox ItemsSource="{Binding Path=Locations[0].Buildings}"> the problem is that I need a dynamic index and <ListBox ItemsSource="{Binding Path=Locations[index].Buildings}"> where index is an integer in my viewmodel, does not work. Does anyone know how I can associate the index in my xaml with the property in my viewmodel? 回答1: where index is an integer in my viewmodel, does

Rounding a Value in the WPF Binding

三世轮回 提交于 2021-02-04 18:49:43
问题 I'm attempting to implement a progress bar with a textbox on top that also displays the progress %. However the percentage is fractional. Is it possible to round a value returned in the dataset via the binding or does it have to be done via the code behind? <ProgressBar Grid.Row="2" Grid.ColumnSpan="2" Height="25" HorizontalAlignment="Stretch" Margin="5,5,5,2" Name="pbProgressIndex" VerticalAlignment="Top" Width="Auto" Value="{Binding Path=ProgressIndex, Mode=OneWayToSource}" /> <TextBlock

Rounding a Value in the WPF Binding

自闭症网瘾萝莉.ら 提交于 2021-02-04 18:49:06
问题 I'm attempting to implement a progress bar with a textbox on top that also displays the progress %. However the percentage is fractional. Is it possible to round a value returned in the dataset via the binding or does it have to be done via the code behind? <ProgressBar Grid.Row="2" Grid.ColumnSpan="2" Height="25" HorizontalAlignment="Stretch" Margin="5,5,5,2" Name="pbProgressIndex" VerticalAlignment="Top" Width="Auto" Value="{Binding Path=ProgressIndex, Mode=OneWayToSource}" /> <TextBlock

WPF Image control not disposing source

核能气质少年 提交于 2021-02-04 18:30:09
问题 I've read multiple threads about this, but still cannot find anything that works. I'm writing program for basically browsing database of images. I have a ListView with DataTemplate: <DataTemplate> <Grid Width="Auto" Height="Auto" > <Image VerticalAlignment="Center" Source="{Binding IsAsync=True, Converter={StaticResource Converter}, ConverterParameter={x:Static viewModel:SearchViewModel.MiniaturesHeight}}" Grid.RowSpan="2" Stretch="None" Margin="5" Height="{Binding Source={StaticResource

WPF DataBinding Thread Safety

馋奶兔 提交于 2021-02-04 16:08:58
问题 I have a TextBox that's bound to a property that gets modified at a very rapid rate in a background thread. Is data binding in WPF thread safe? Will the data in the property or the TextBox ever get out of sync? Is it necessary (or even possible) to use synchronization on a property that takes part in data binding? I understand that, if the class on which the property resides implements INotifyPropertyChanged, the binding framework automatically marshalls the UI update to the UI thread.

WPF DataBinding Thread Safety

允我心安 提交于 2021-02-04 16:08:39
问题 I have a TextBox that's bound to a property that gets modified at a very rapid rate in a background thread. Is data binding in WPF thread safe? Will the data in the property or the TextBox ever get out of sync? Is it necessary (or even possible) to use synchronization on a property that takes part in data binding? I understand that, if the class on which the property resides implements INotifyPropertyChanged, the binding framework automatically marshalls the UI update to the UI thread.

WPF Binding can't find data item

倾然丶 夕夏残阳落幕 提交于 2021-01-29 19:17:58
问题 I am quite new to the concept of data binding and MVVM, so I've been trying it out the past couple of days. Basically, what I'm trying to do is using the LiveCharts library, I want to display multiple charts at the same time from an uploaded CSV file. I am doing well so far, but now I am writing code so that if I want to increase the units in the X-Axis in one chart, I can do so simultaneously with the others. (For context, the x-axis is in the timestamp unit, and the different charts should

WPF In-Memory Image Display

一世执手 提交于 2021-01-29 14:50:30
问题 Im trying to build an Item Template for my list-view and im bound to a list of Entities. The entity I have has a System.Drawing.Image that I'd like to display, but so far I cannot for the life of me figure out how to bind it to the <Image> block. Every example and documentation I can find on the internet pertains to Images accessible via an uri i.e. File on HDD or On Website <DataTemplate x:Key="LogoPreviewItem"> <Border BorderBrush="Black" BorderThickness="1"> <DockPanel Width="150" Height=

Binding from UI to view model property requires focus to be removed from the TextBox

孤人 提交于 2021-01-29 12:50:49
问题 I am using MVVM. I have a DataGrid which lists some airports. Now I have a textbox let the user to input some keywords to search for a particular airport so that the airport list will only display matched airports. private string airport; public string Airport { get { return airport; } //the following will not be executed unless the cursor is removed from the textbox set { airport = value; //OnPropertyChanged("Airport"); } } view: <TextBox x:Name="textBox_Airport" Text="{Binding Airport}"> <i

Items not displaying in RecyclerView

北城以北 提交于 2021-01-29 12:30:48
问题 That's a weird problem I'm facing right now. From my app, I'm fetch data from JSON file from a link then parse it with Volley. Now I want to display the data on a RecyclerView which doesn't seem to work, I'm pretty dure that my code is good but something doesn't seem to work and I can't find it. activity_home.xml This seems to render as I tested wiht background color: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas