Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView.ItemContainerStyle resets all Style settings #1257

Open
mani9876 opened this issue Oct 20, 2024 · 3 comments
Open

ListView.ItemContainerStyle resets all Style settings #1257

mani9876 opened this issue Oct 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@mani9876
Copy link

Describe the bug

Hello,

as an example, I am defining a ui:ListView:

<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

@mani9876 mani9876 added the bug Something isn't working label Oct 20, 2024
@Micaias-Bobadilla
Copy link

Micaias-Bobadilla commented Oct 30, 2024

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
Copy link

same problem

@Mechatrony
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants