我有一个简单的 WPF 应用程序,它使用从绑定列表收集的数据填充行,它看起来像这样:

现在你可以看到我的第一列是空的,但我想写下取决于sts列的信息。例如:如果sts == 8我想在第一个空白列中写下字母 R 并在sts == 0. 我怎样才能做到这一点?这是我的 WPF 的回溯代码:
<DataGrid AutoGenerateColumns="False" Background="White" Height="316" HorizontalAlignment="Left" Name="dataGrid1" VerticalAlignment="Top" Width="640" SelectionMode="Single" IsReadOnly="True" ItemsSource="{Binding Oblista}" AutoGeneratingColumn="generiseColumn" >
<!---->
<DataGrid.Resources>
<Style TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/>
<EventSetter Event="MouseRightButtonDown" Handler="Row_RightCLick"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn />
<DataGridTextColumn Header="sts" Width="50" Binding="{Binding cflag}"/>
<DataGridTextColumn Header="Adresa" Width="80" Binding="{Binding Sadr_reg}"/>
<DataGridTextColumn Header="Opis" Width="200" Binding="{Binding naziv}"/>
<DataGridTextColumn Header="Tip" Width="80" Binding="{Binding Stip_reg}"/>
<DataGridTextColumn Header="Vrednost" Width="80" Binding="{Binding sVal}"/>
<DataGridTextColumn Header="Min" Width="40" Binding="{Binding lo_limit}"/>
<DataGridTextColumn Header="Max" Width="40" Binding="{Binding hi_limit}"/>
<DataGridTextColumn Header="Rw" Width="40" Binding="{Binding write}"/>
</DataGrid.Columns>
</DataGrid>
XAML.CS:
public BindingList<PIO_CARD> Oblista = new BindingList<PIO_CARD>();
public MainWindow()
{
InitializeComponent();
dataGrid1.ItemsSource = Oblista;
}
慕的地6264312
繁星淼淼
噜噜哒
随时随地看视频慕课网APP
相关分类