lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.74k stars 756 forks source link

ListView.ItemContainerStyle resets all Style settings #1257

Open mani9876 opened 1 month ago

mani9876 commented 1 month ago

Describe the bug

Hello,

as an example, I am defining a :

<ui:ListView Grid.Row="1" Grid.ColumnSpan="1">
  <ui:ListView.View>
    <ui:GridView>
        <GridViewColumn Header="Test" Width="100">
            <GridViewColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}"/>
                </DataTemplate>
            </GridViewColumn.CellTemplate>
        </GridViewColumn>
    </ui:GridView>
</ui:ListView.View>
<ListViewItem>
    <ListViewItem.Content>
        <x:Array Type="{x:Type sys:String}">
            <sys:String>Test</sys:String>
        </x:Array>
    </ListViewItem.Content>
</ListViewItem>
<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
    </Style>
</ListView.ItemContainerStyle>
</ui:ListView>`

As soon as

  <ListView.ItemContainerStyle>
     <Style TargetType="ListViewItem">
     </Style>
 </ListView.ItemContainerStyle>`

is applied, every Style setting from WPF-UI is gone. Also there is no possibility for BasedOn.

Am I missing something, or is that a Bug?

Thanks!

To Reproduce

See the example above.

Expected behavior

The Style settings from WPF-UI should remain, only the settings changed should be changed.

Screenshots

No response

OS version

Windows 11

.NET version

.NET 8.0

WPF-UI NuGet version

recent stable, and also on preview.

Additional context

No response

Micaias-Bobadilla commented 1 month ago

I have the same problem, when I put a trigger in my TextBox and PasswordBox, which change borderBrush when the pass and user is wrong.

Edit: The way I solved it was to implement an event in the viewModel, and subscribe to a method in the code behind of the view, to change only the border color. That way the style of the UI controls was not removed:

Re edit: Only in ListView is no BaseOn, to do BaseOn="{StaticResource= {Type=ui:ListView}}" in others controls works perfectly, try use other control

huiyadanli commented 3 weeks ago

same problem

Mechatrony commented 3 weeks ago

Set TargetType="ui:ListViewItem", not TargetType="ListViewItem"

<ListView.ItemContainerStyle>
  <Style TargetType="ui:ListViewItem" BasedOn="{StaticResource ListViewItemStyle}">
  </Style>
</ListView.ItemContainerStyle>