binding

Bind static data as dictionary key

自古美人都是妖i 提交于 2020-01-30 11:32:22
问题 How to bind dictionary static data as dictionary key? My XAML code: <TextBlock x:Name="AxisXTextBlock" Width="37" Height="18" Margin="106,19,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="Source Code Pro" Text="{Binding DataStructure.DictionaryOfValuesReadOnly[AXIS_X].IntValue, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" /> Class of static data for keys of dictionaries: public static class DataNames { public static string SomeDataName { get; } =

Bind static data as dictionary key

筅森魡賤 提交于 2020-01-30 11:31:08
问题 How to bind dictionary static data as dictionary key? My XAML code: <TextBlock x:Name="AxisXTextBlock" Width="37" Height="18" Margin="106,19,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="Source Code Pro" Text="{Binding DataStructure.DictionaryOfValuesReadOnly[AXIS_X].IntValue, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" /> Class of static data for keys of dictionaries: public static class DataNames { public static string SomeDataName { get; } =

WPF XAML Change Style Template Property for Some Elements

旧街凉风 提交于 2020-01-30 11:27:26
问题 In a WPF application I have a style used for buttons: <Style TargetType="Button" x:Key="ButtonEllipse"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <StackPanel Orientation="Vertical"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 0 10"/> <Image x:Name="ButtonImage" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="/MyProject;component/Images/ButtonEllipse.png"/> </StackPanel> <

WPF XAML Change Style Template Property for Some Elements

£可爱£侵袭症+ 提交于 2020-01-30 11:27:26
问题 In a WPF application I have a style used for buttons: <Style TargetType="Button" x:Key="ButtonEllipse"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <StackPanel Orientation="Vertical"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 0 10"/> <Image x:Name="ButtonImage" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" Source="/MyProject;component/Images/ButtonEllipse.png"/> </StackPanel> <

Converter shows System.Data.Entity.DynamicProxies when bind to EF Model

。_饼干妹妹 提交于 2020-01-30 08:17:06
问题 I am writing a WPF MVVM Application. I am trying to use a converter to display a contact name in the combobox. I do not think I can use the DisplayMemberPath since a "fullname" column does not exist. The ComboBox is being bound to a class within a class using Entity Framework. Given the following: .cs Files public class Car { public int CarId { get; set; } public string Make { get; set; } public string Model { get; set; } public string Year { get; set; } public Contact Owner { get; set; } }

Make TextBlock Bold only if certain condition is true, via Binding

心不动则不痛 提交于 2020-01-29 10:29:21
问题 How can I define a TextBlock as FontStyle is Bold, via a Binding to a bool ? <TextBlock Text="{Binding Name}" FontStyle="???"> And I'd really like to bind it to public bool NewEpisodesAvailable { get { return _newEpisodesAvailable; } set { _newEpisodesAvailable = value; OnPropertyChanged(); } } Is there a way to achieve this, or should my Model property do the translation for me, instead of presenting a bool present the FontStyle directly? 回答1: You can achieve that via DataTrigger like this:

Binding a WPF Button CommandParameter to the Button itself in DataTemplate

做~自己de王妃 提交于 2020-01-29 06:38:26
问题 I have a DataTemplate that represents AppBar buttons that I declare through a collection of custom AppBarCommand objects. public AppBarCommand(RelayCommand command, string buttonstyle) { Command = command; ButtonStyle = buttonstyle; } <DataTemplate> <Button Command="{Binding Command}" Style="{Binding ButtonStyle, Converter={StaticResource StringNameToStyleConverter}}"/> </DataTemplate> I would like to add a CommandParameter binding, but the parameter has to be the Button itself. This is so I

Binding a WPF Button CommandParameter to the Button itself in DataTemplate

為{幸葍}努か 提交于 2020-01-29 06:38:05
问题 I have a DataTemplate that represents AppBar buttons that I declare through a collection of custom AppBarCommand objects. public AppBarCommand(RelayCommand command, string buttonstyle) { Command = command; ButtonStyle = buttonstyle; } <DataTemplate> <Button Command="{Binding Command}" Style="{Binding ButtonStyle, Converter={StaticResource StringNameToStyleConverter}}"/> </DataTemplate> I would like to add a CommandParameter binding, but the parameter has to be the Button itself. This is so I

Vue bind click that adds active class (and removes from the last one)

不羁岁月 提交于 2020-01-25 21:13:46
问题 I have a v-for loop that adds a section of divs to the page. On page load, the first one should be selected and then when you click another one, it should add the active class to the clicked div and remove the active class from the last div. I tried the following which does not work. Any suggestions? <div class="col-sm-6" v-for="(area, index) in areaSections"> <section class="monitoring-areas section" v-on:click="changeActive()"> <h3> Area {{index + 1}}: {{area.title}} <span class="section

Bind ObservableCollection to database

限于喜欢 提交于 2020-01-25 10:52:08
问题 I have the following class: [Table] public class myClass { [Column(IsPrimaryKey = true)] public int ID { get; set; } [Column] public string Type { get; set; } } And the following code in order to load the data from my database table "myClass": static public readonly ObservableCollection<myClass> items; DataContext dataContext = new DataContext("Secret"); var ruleTable = dataContext.GetTable<myClass>(); IQueryable<Rule> custQuery = ruleTable.Select(tableName => tableName); items = new