HandyOrg / HandyControl

Contains some simple and commonly used WPF controls
https://handyorg.github.io/
MIT License
6.11k stars 1.03k forks source link

TabControl 控件使用MVVM方式进行绑定,是否可以设置某个TabItem不允许关闭? #1619

Closed 2270969436 closed 3 months ago

2270969436 commented 3 months ago

Describe the bug

HandyControl的Demo的MVVM示例代码里面没看到设置TabItem控件ShowCloseButton属性的方法。 虽然我知道在XAML的TabItem可以设置属性,但我希望在MVVM模式下,也能进行这一项的设置。然后其中某些TabItem不允许关闭,部分TabItem可以关闭

Steps to reproduce the bug

            <hc:TabControl Grid.Row="2" IsAnimationEnabled="True" Margin="0,32,0,0" ShowCloseButton="True" IsDraggable="True" ItemsSource="{Binding DataList}" MaxWidth="800" Height="300" OverflowMenuDisplayMemberPath="Header">
                <TabControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Header}"/>
                    </DataTemplate>
                </TabControl.ItemTemplate>
                <TabControl.ContentTemplate>
                    <DataTemplate>
                        <hc:SimplePanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{Binding BackgroundToken,Converter={StaticResource String2BrushConverter}}"/>
                    </DataTemplate>
                </TabControl.ContentTemplate>
            </hc:TabControl>

Expected behavior

No response

Screenshots

No response

NuGet package version

HandyControl 3.4.0

IDE

Visual Studio 2022

Framework type

.Net 6.0

Windows version

Windows 11 (22000)

Additional context

No response

2270969436 commented 3 months ago

找到了,ItemsSource直接绑定TabItem集合就可以了