microsoft / microsoft/microsoft-ui-xaml
Applying dependencyProperty in the case of string type
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
I created the UserControl with the following DependecyProperty:
```
public string? Text
{
get => (string?)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.RegisterAttached(nameof(Text), typeof(string), typeof(ColoredStringBox), new PropertyMetadata(null));
```
When the UserControl is used on one of my pages where the property Text has the value null, I would expect the same value of Text property inside UserControl, but unfortunately, the value is equal to ""(string.Empty). Is there any special reason for this or is it a bug?
### Steps to reproduce the bug
Please check the problem description!
### Expected behavior
_No response_
### Screenshots
_No response_
### NuGet package version
None
### Windows version
_No response_
### Additional context
_No response_
Contributor guide
Research direction
The report names a UserControl and a registered DependencyProperty but provides no repository file, test, or runnable reproduction. Start by locating the dependency-property registration and related string-value handling in the WinUI codebase, then reproduce the null-to-empty behavior. Done means the behavior is explained and covered by a reliable regression test or the issue is documented as expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100