亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

盡管將 IsDeleteble 屬性設置為“IsDeletable = true”,但我無法刪除芯片

盡管將 IsDeleteble 屬性設置為“IsDeletable = true”,但我無法刪除芯片

C#
忽然笑 2022-12-24 10:58:59
盡管將 IsDeletable 屬性設置為 IsDeletable=True,但我一直單擊芯片刪除圖標但沒有任何反應。如何刪除芯片點擊刪除圖標?主窗口.xaml    <StackPanel Orientation="Horizontal" x:Name="addchip">        <Button Click="create_chip">delete_chip</Button>        <materialDesign:Chip  Content="Example Chip"  ToolTip="This is an example chip" IsDeletable="True"/>    </StackPanel>主窗口.xaml.cspublic partial class MainWindow : Window{    public MainWindow()    {        InitializeComponent();    }    private void deletenotify(object sender, RoutedEventArgs e)    {        Debug.WriteLine("delete!");    }    private void create_chip(object sender, RoutedEventArgs e)    {        Chip a = new Chip();        a.Content = "Example Chip";        a.IsDeletable =true ;        a.DeleteClick += deletenotify;        addchip.Children.Add(a);    }}
查看完整描述

1 回答

?
溫溫醬

TA貢獻1752條經驗 獲得超4個贊

試試這個:

輸出:

https://i.stack.imgur.com/sg0v2.gif

Xaml:


<Window x:Class="TestChipDeleting.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        mc:Ignorable="d"

        Title="MainWindow" 

        Height="400" 

        Width="300"

        Loaded="MainWindow_OnLoaded">

    <Grid>

        <ItemsControl Name="UsersListBox">


        </ItemsControl>

    </Grid>

</Window>

C#:


using System.Windows;

using MaterialDesignThemes.Wpf;


namespace TestChipDeleting

{

    public partial class MainWindow

    {

        public MainWindow()

        {

            InitializeComponent();

        }


        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)

        {

            BindUsers();

        }


        private void Chip_OnDeleteClick(object sender, RoutedEventArgs e)

        {

            var currentChip = (Chip) sender;

            UsersListBox.Items.Remove(currentChip);

        }


        private void BindUsers()

        {

            for (var i = 0; i < 10; i++)

            {

                var chip = new Chip {IsDeletable = true};

                chip.DeleteClick += Chip_OnDeleteClick;

                chip.Content = "Username" + i;

                chip.Icon = i;

                UsersListBox.Items.Add(chip);

            }

        }



    }

}


查看完整回答
反對 回復 2022-12-24
  • 1 回答
  • 0 關注
  • 127 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號