C# pestring。知道了? DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.4) }; timer.Tick += delegate (obje

C# pestring。知道了? DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.4) }; timer.Tick += delegate (obje,c#,uwp,C#,Uwp,pestring。知道了? DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.4) }; timer.Tick += delegate (object sender, object e) { if(selectedItem != null && selectedItem.ToString() != MiniTextBlock.Text) {

pe
string
。知道了?
DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.4) };
timer.Tick += delegate (object sender, object e)
{

    if(selectedItem != null && selectedItem.ToString() != MiniTextBlock.Text)
    {
        FavoritesListBox.SelectedIndex = -1;
    }
};
timer.Start();
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <TextBlock Name="MiniTextBlock" Text="35" FontSize="50" VerticalAlignment="Top" HorizontalAlignment="Center"/>

        <ListBox Name="FavoritesListBox" VerticalAlignment="Center">
            <ListBoxItem>
                <TextBlock Text="36" FontSize="30"/>
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="35" FontSize="30"/>
            </ListBoxItem>
            <ListBoxItem>
                <TextBlock Text="34" FontSize="30"/>
            </ListBoxItem>
        </ListBox>
    </StackPanel>
public MainPage()
{
    this.InitializeComponent();
    DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.4) };
    timer.Tick += delegate (object sender, object e)
    {
        var selectedItem = FavoritesListBox.SelectedItem;

        if (selectedItem != null && selectedItem.ToString() != MiniTextBlock.Text)
        {
            FavoritesListBox.SelectedIndex = -1;
        }
    };
    timer.Start();
}
var selectedItem = FavoritesListBox.SelectedItem;

if(selectedItem != null && selectedItem.ToString() != MiniTextBLock.Text)
{
    FavoritesListBox.SelectedIndex = -1;
}
timer.Tick += delegate (object sender, object e)
{
    var selectedItem = (ListBoxItem)FavoritesListBox.SelectedItem;

    if (selectedItem == null)
    {
        return;
    }

    var tb = (TextBlock)selectedItem.Content;

    if (tb.Text != MiniTextBlock.Text)
    {
        FavoritesListBox.SelectedIndex = -1;
    }
};