[英]Limit IntegerUpDown to a specific set of numbers on WPF
我是WPF的新手,我需要做一些事情,但是找不到在哪里做(我知道這應該是可能的,因為C#表單上有類似的對象),我想限制IntegerUpDown的數據集在wpf表單st上,默認值是1到64,為2的冪,問題是沒有地方告訴我如何做到這一點(通過我的google搜索和microsoft網站),有什么幫助嗎?
我認為組合框不好,但是您有任何線索為什么它不能識別樣式? (位於同一文件上...)即時添加組合框-
<xctk:ComboBox Canvas.Left="334" Canvas.Top="80" FormatString=""
Maximum="64" Minimum="2" Name="integerUpDownFrameAvg" Style="{StaticResource myComboBoxStyle}"
Text="0" Value="0" Width="60" DataContext="{Binding}">
<ComboBoxItem Content="1"></ComboBoxItem>
<ComboBoxItem Content="2"></ComboBoxItem>
<ComboBoxItem Content="4"></ComboBoxItem>
<ComboBoxItem Content="8"></ComboBoxItem>
<ComboBoxItem Content="16"></ComboBoxItem>
<ComboBoxItem Content="32"></ComboBoxItem>
<ComboBoxItem Content="64"></ComboBoxItem>
</xctk:ComboBox>
那就是風格-
<Style x:Key="myComboBoxStyle"
TargetType="xctk:ComboBox">
<Setter Property="FontSize"
Value="12" />
<Setter Property="Foreground"
Value="White" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="Background"
Value="#FF4A4A3C" />
<Setter Property="BorderBrush"
Value="Black" />
<Setter Property="Width"
Value="60" />
<Setter Property="Height"
Value="20" />
我包括了-
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
在標題上,盡管錯誤缺少程序集,但仍然可以正常工作...
那你為什么不使用ComboBox
:
<ComboBox Name="intComboBox">
<ComboBoxItem Content="1"></ComboBoxItem>
<ComboBoxItem Content="2"></ComboBoxItem>
<ComboBoxItem Content="4"></ComboBoxItem>
<ComboBoxItem Content="8"></ComboBoxItem>
<ComboBoxItem Content="16"></ComboBoxItem>
<ComboBoxItem Content="32"></ComboBoxItem>
<ComboBoxItem Content="64"></ComboBoxItem>
</ComboBox>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.