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

ObservableCollection does not work correctly with the controls #63

Open
MajorXAML opened this issue Feb 15, 2022 · 5 comments
Open

ObservableCollection does not work correctly with the controls #63

MajorXAML opened this issue Feb 15, 2022 · 5 comments
Assignees
Labels
controls Changes to the appearance or logic of custom controls. enhancement New feature or request styles Topic is related to styles

Comments

@MajorXAML
Copy link
Contributor

If we try to add any control via code using ObservableCollection, we won't get the desired result.
for example:

public ObservableCollection<WPFUI.Controls.Card> TestColl { get; set; } = new ObservableCollection<WPFUI.Controls.Card>();

TestTest.Add(new WPFUI.Controls.Card {Content = "Test"});

The result will be just Test text without any style

Similar behavior can be seen in the Demo > Controls > DataGrid
data grid
As you see the checkboxes use the default windows style.

Maybe someone knows why this happens? I have not yet tested other ui libraries, wonder how they handle it.

@MajorXAML MajorXAML changed the title ObservableCollection does not work correctly with the library ObservableCollection does not work correctly with the controls Feb 15, 2022
@pomianowski pomianowski added controls Changes to the appearance or logic of custom controls. enhancement New feature or request styles Topic is related to styles labels Feb 16, 2022
@MajorXAML
Copy link
Contributor Author

Quick update.
I checked ModernWPF and adding controls via code works without any problems! I have an assumption that the problem is in the way we connect the library. Modernwpf does this using xmlns 🤨

@pomianowski
Copy link
Member

At the moment, the DataGrid is simply added with the background and basic stuff, I did not go into this control because it requires a thorough redesign. In free time, it will be rewritten

@MajorXAML
Copy link
Contributor Author

MajorXAML commented Feb 16, 2022

At the moment, the DataGrid is simply added with the background and basic stuff, I did not go into this control because it requires a thorough redesign. In free time, it will be rewritten

Yes, I understand. But I pointed out the CheckBoxes. Any control we add through code will look completely unstyled.

@pomianowski
Copy link
Member

Binding controls seems to just work, DataGrid has own styles for CheckBoxes etc
image

@MajorXAML
Copy link
Contributor Author

CollTest
I think I figured it out, this happens only with ItemsControl, for some unknown reason ItemContainerStyle resets all styles
of all the controls inside... This didn't happen in modernwpf or when using UserControls. But I think I can find a workaround for my case.

As for DataGrid, it's a similar situation. DataGrid should use global styles for controls (like checkbox) provided by the library. But it feels like it's just isolated from other UI elements... I checked DataGrid in modernwpf and the checkboxes are fine. I can replace them with any other control and it will work.
datagrid

Anyway, thanks for helping me figure out the cause! If I find a way to fix datagrid I will let you know.

@pomianowski pomianowski self-assigned this Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls Changes to the appearance or logic of custom controls. enhancement New feature or request styles Topic is related to styles
Projects
None yet
Development

No branches or pull requests

2 participants