Can't set Text Property programmatically
Describe the bug
When I set .Text in code, the property changes it's value, but this text doesn't appear in the TextBox.
<Window
x:Class="TokenizingTextBox_Text_BUG.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
mc:Ignorable="d">
<controls:TokenizingTextBox ItemClick="TokenizingTextBox_ItemClick"
PlaceholderText="Add and click token to set the Text property" />
</Window>
using CommunityToolkit.WinUI.UI.Controls;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace TokenizingTextBox_Text_BUG;
sealed partial class MainWindow : Window
{
public MainWindow() => InitializeComponent();
void TokenizingTextBox_ItemClick(object sender, ItemClickEventArgs e)
{
if (sender is TokenizingTextBox tokenBox)
tokenBox.Text = (string)e.ClickedItem;
}
}
Steps to reproduce
#
tokenBox.Text = "some value";
Expected behavior
Text appears in the text box.
Screenshots
No response
Code Platform
- [ ] UWP
- [X] WinAppSDK / WinUI 3
- [ ] Web Assembly (WASM)
- [ ] Android
- [ ] iOS
- [ ] MacOS
- [ ] Linux / GTK
Windows Build Number
- [ ] Windows 10 1809 (Build 17763)
- [ ] Windows 10 1903 (Build 18362)
- [ ] Windows 10 1909 (Build 18363)
- [ ] Windows 10 2004 (Build 19041)
- [ ] Windows 10 20H2 (Build 19042)
- [ ] Windows 10 21H1 (Build 19043)
- [ ] Windows 10 21H2 (Build 19044)
- [X] Windows 10 22H2 (Build 19045)
- [ ] Windows 11 21H2 (Build 22000)
- [ ] Other (specify)
Other Windows Build number
No response
App minimum and target SDK version
- [ ] Windows 10, version 1809 (Build 17763)
- [ ] Windows 10, version 1903 (Build 18362)
- [ ] Windows 10, version 1909 (Build 18363)
- [ ] Windows 10, version 2004 (Build 19041)
- [ ] Windows 10, version 2104 (Build 20348)
- [ ] Windows 11, version 22H2 (Build 22000)
- [ ] Other (specify)
Other SDK version
No response
Visual Studio Version
No response
Visual Studio Build Number
17.9.0 Preview 2.0
Device form factor
Desktop
Additional context
No response
Help us help you
Yes, but only if others can assist.
Shouldn't there be a x:Name="tokenBox" in the xaml?
Shouldn't there be a
x:Name="tokenBox"in the xaml?
It is not necessary, we get it from the sender argument in the example
The version 8.0 works fine.
@OZ1 yes, I believe this was a bug we fixed between versions. Can I close this issue now then?
When the links are up to date, I think it should be closed.