There is no similar linkbutton in WPF, so only the button and style are used to implement LinkButton.
The DataGrid Action column implements several similar LinkButton buttons:
The specific implementation code is as follows:
<datagrid name="Dgdata"isreadonly="true"autogeneratecolumns="False"> <DataGrid.Columns> <datagridtemplatecolumn header="Operation"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <sta Ckpanel orientation="Horizontal"> <button name="Btninput"Content="Filling Order"Cursor="Hand"click="Btninput_click"margin="5,0,5,0"> <Button.Template> <controltemplate targettype="Button"> <textblock textdecorations="Underline"Name="Btninput"> <contentpresenter/> </TEXTB Lock> </ControlTemplate> </Button.Template> <Button.Style> <style targettype="Button"> <setter property="Foreground"Value="Blue"/> <Style.Triggers> <trigger Propert y="IsMouseOver"Value="true"> <setter property="Foreground"Value="Red"/> </Trigger> </Style.Triggers> </Style> </Button.Style> </ Button> <button name="Btncancel"Content="Cancel"Cursor="Hand"click="Btncancel_click"margin="5,0,5,0"> <Button.Template> <controltemplate targettype="Button"> <textblock textdecorations="Underline"Name="Btncancel"> <contentpresenter/> </TextBlock> </ControlTemplate> </Button.Template> <Button.Style> <style targettype="Button"> <setter property="Foreground"Value="Blue"/> <Style.Triggers> <trigger Propert y="IsMouseOver"Value="true"> <setter property="Foreground"Value="Red"/> </Trigger> </Style.Triggers> </Style> </Button.Style> </ button> </StackPanel> </DataTemplate> </datagridtemplatecol Umn. Celltemplate> </DataGridTemplateColumn> </DataGrid.Columns></DataGrid>
Front Code
Private voidBtninput_click (Objectsender, RoutedEventArgs e) {DataRowView DRV= This. Dgdata.currentitem asDataRowView; if(DRV! =NULL) { stringID = DRV. row["ID"]. ToString (); }}Private voidBtncancel_click (Objectsender, RoutedEventArgs e) {DataRowView DRV= This. Dgdata.currentitem asDataRowView; if(DRV! =NULL) { stringID = DRV. row["ID"]. ToString (); }}
Background Code
Just start contacting WPF, if there's something wrong with it.
WPF DataGrid Action column is similar to LinkButton