简体   繁体   中英

icon in datagrid context menu don't work

I am trying to add an icon to a datagrid context menu however altough I added the file to the folder and changed it to copy always.

The context menu do not show the photo. insted he write the photo path:"Delete-icon.ico" would be happy for an answer thanks,

<DataGrid x:Name="DGData" Grid.Column="2" PreviewKeyDown="DGData_PreviewKeyDown" IsReadOnly="True">
    <DataGrid.Columns>

    </DataGrid.Columns>

    <DataGrid.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Delete"  Click="MenuItem_Click" Icon="Delete-icon.ico"></MenuItem>
        </ContextMenu>
    </DataGrid.ContextMenu>
</DataGrid>

Set the Icon property to an Image :

<MenuItem Header="Delete" Click="MenuItem_Click">
    <MenuItem.Icon>
        <Image Source="Delete-icon.ico" />
    </MenuItem.Icon>
</MenuItem>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM