我正在使用ListBox
我使用PlaceholderText
TextBox
属性的ListBox
。这是我PopUp
的代码。我使用A <Popup x:Name="ReasonCodePopUp" x:FieldModifier="Public" IsOpen="{Binding ShowFuelChangeReasonPopUp, Mode=TwoWay}"
Height="420" Width="1100" Grid.Row="0" Grid.RowSpan="2" IsLightDismissEnabled="True">
<Grid Height="397" Width="1100" >
<TextBlock Visibility="Collapsed" Name="txtFuelReason" Text="{x:Bind ViewModel.FuelPlanInfo.ExtraFuelReason,Mode=TwoWay}"/>
<ListBox Margin="20" Name="lstFuelReason" SelectionChanged="lstFuelReason_SelectionChanged"
Background="#414042" Height="420" Width="1100" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Padding" Value="0"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBoxItem IsEnabled="False" Margin="43.5,30.5,748.5,0">
<TextBlock Text="Reason Code" FontSize="32" FontFamily="Helvetica" FontWeight="Bold" Foreground="#ffffff" IsHitTestVisible="False" />
</ListBoxItem>
<ListBoxItem IsEnabled="False">
<Border Margin="43,0,57,0" BorderBrush="#979797" BorderThickness="0,0,0,1" Width="948"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="ATC" Margin="43,0,57,0" Foreground="#FFFFFF" FontSize="32" FontFamily="{ThemeResource Bold}" FontWeight="Normal" SelectionHighlightColor="Blue"></TextBlock>
</ListBoxItem>
<ListBoxItem IsEnabled="False">
<Border Margin="43,0,57,0" BorderBrush="#979797" BorderThickness="0,0,0,1" Width="948"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Text="Weather" Margin="43,0,57,0" Foreground="#FFFFFF" FontSize="32" FontFamily="{ThemeResource Bold}" FontWeight="Normal"></TextBlock>
</ListBoxItem>
<ListBoxItem IsEnabled="False" Margin="0">
<Border Margin="43,0,57,0" BorderBrush="#979797" BorderThickness="0,0,0,1" Width="948"/>
</ListBoxItem>
<ListBoxItem Height="50">
<TextBox PlaceholderText="Other" Margin="43.5,0,0,0" Tapped="FuelReasonOther_Tapped" TextChanged="TextBox_TextChanged" Foreground="#FF0078D7" FontSize="32" FontFamily="{ThemeResource Bold}" FontWeight="Normal" Style="{StaticResource TransparentTextBox}"/>
</ListBoxItem>
</ListBox>
</Grid>
</Popup>
来实现内容
<TextBox PlaceholderText="Other"/>
我希望Blue
修改“其他”的前景颜色以及此处输入的文字以显示在ContentTemplate
中。
我知道我需要玩clock_t stime = clock();
sleep(3);
clock_t etime = clock();
// print etime and stime and (etime - stime) * 1000 and CLOCKS_PER_SEC
unsigned long millis = ((etime - stime) * 1000) / CLOCKS_PER_SEC;
printf("%lu\n",millis);
但不能这样做。
有人可以帮忙吗?
答案 0 :(得分:0)
如果覆盖TextControl定义的画笔,则可以将颜色更改为所需的颜色,而无需主题化整个TextBox控件。我使用以下代码对其进行了测试,并且有效:
<TextBox PlaceholderText="Other" Margin="43.5,0,0,0" FontSize="32" FontWeight="Normal">
<TextBox.Resources>
<SolidColorBrush x:Key="TextControlPlaceholderForeground" Color="LightBlue"/>
<SolidColorBrush x:Key="TextControlPlaceholderForegroundFocused" Color="LightBlue" />
<SolidColorBrush x:Key="TextControlPlaceholderForegroundPointerOver" Color="LightBlue" />
<SolidColorBrush x:Key="TextControlForeground" Color="Blue" />
<SolidColorBrush x:Key="TextControlForegroundFocused" Color="Blue" />
<SolidColorBrush x:Key="TextControlForegroundPointerOver" Color="Blue" />
</TextBox.Resources>
</TextBox>
注意:我删除了绑定和事件处理程序以仅保留UI元素。但是您应该能够将TextBox.Resources添加到TextBox中并查看它是否有效。
TextBox.Resources覆盖TextControl的默认画笔(在TextBox中)。控件使用这些画笔名称在特定情况下绘制。
如果这样做,请告诉我。