完成数据绑定

This commit is contained in:
hsc 2025-11-10 10:07:10 +08:00
parent e25c2cd3d9
commit 7e19e55e39
5 changed files with 14 additions and 8 deletions

View File

@ -26,7 +26,7 @@
<ResourceDictionary Source="Resources\Styles\WindowStyle.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="TextBox"
BasedOn="{StaticResource MaterialDesignTextBox}">
BasedOn="{StaticResource MaterialDesignFilledTextBox}">
<!-- 禁用自动化属性,避免 null 报错 -->
<Setter Property="AutomationProperties.Name"
Value="" />

View File

@ -178,7 +178,7 @@ namespace BOB.ViewModels.Dialogs
{
Device = new();
IsAdd = true;
Device.Type = "TCP";
Device.Type = "Tcp";
SelectionChanged();
}
else

View File

@ -18,7 +18,12 @@ namespace BOB.ViewModels
get => _SelectedStep;
set => SetProperty(ref _SelectedStep, value);
}
private ProgramModel _Program;
public ProgramModel Program
{
get => _Program;
set => SetProperty(ref _Program, value);
}
#endregion
private GlobalVariables _globalVariables;
private IEventAggregator _eventAggregator;
@ -32,6 +37,7 @@ namespace BOB.ViewModels
CancelEditCommand = new DelegateCommand(CancelEdit);
SaveStepCommand = new DelegateCommand(SaveStep);
_eventAggregator.GetEvent<DeletedStepEvent>().Subscribe(DisposeSelectedStep);
Program = _globalVariables.Program;
}
private void DisposeSelectedStep(Guid id)

View File

@ -38,7 +38,6 @@
VerticalAlignment="Bottom"
Content="参数名称*" />
<TextBox Width="120"
VerticalAlignment="Bottom"
Text="{Binding Parameter.Name}" />
</StackPanel>
<StackPanel Height="30"

View File

@ -43,6 +43,7 @@
<Label Width="60"
Content="名称" />
<TextBox MinWidth="120"
Text="{Binding SelectedStep.Name}" />
</StackPanel>
@ -168,7 +169,7 @@
<MultiBinding Converter="{StaticResource FilteredParametersConverter}">
<Binding Path="Type" />
<Binding Path="DataContext.Program.Parameters"
RelativeSource="{RelativeSource AncestorType=Window}" />
RelativeSource="{RelativeSource AncestorType=UserControl}" />
</MultiBinding>
</ComboBox.ItemsSource>
<ComboBox.ItemTemplate>
@ -204,7 +205,7 @@
<MultiBinding Converter="{StaticResource FilteredParametersConverter}">
<Binding Path="Type" />
<Binding Path="DataContext.Program.Parameters"
RelativeSource="{RelativeSource AncestorType=Window}" />
RelativeSource="{RelativeSource AncestorType=UserControl}" />
</MultiBinding>
</ComboBox.ItemsSource>
<ComboBox.ItemTemplate>
@ -286,7 +287,7 @@
<ComboBox Height="22"
MinWidth="120"
VerticalAlignment="Bottom"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.Program.Parameters}"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext.Program.Parameters}"
SelectedValue="{Binding VariableName}"
SelectedValuePath="Name"
Visibility="{Binding IsUseVar, Converter={StaticResource BooleanToVisibilityConverter}}">