0

I am new to WPF, and there is something I need to do but just couldnt find no where how to do it (I do know it should be possible since there is a similar object on C# forms) I want to limit the dataset of IntegerUpDown on a wpf form s.t the default value will be 1 up to 64 as powers of two, problem is there is no place (by my google search and the microsoft website) that tells me how to do that, any help?

I think ill go with the combobox but do you have any clue why it might not recognize the style? (its on the same file...) im adding the combobox as is -

    <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>

that is the style -

<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" />

and I included the -

xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"

on the header, it dosent work though the error is missing an assembly...

crazyPixel
  • 2,301
  • 5
  • 24
  • 48

1 Answers1

2

Then why don't you use a 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>
ProgramFOX
  • 6,131
  • 11
  • 45
  • 51
  • I did - this is not what im looking for though, I need the increment to be as power of two (i.e. 1,2,4,8,16,32,64, and limit the maximum only limit the the top most value) – crazyPixel Oct 06 '13 at 15:37
  • @crazyPixel: I'm sorry, I misunderstood you. I updated my answer. – ProgramFOX Oct 06 '13 at 15:41
  • That is what I know from C# forms problem is the engineer who started the whole app before me decided to use IntegerUpDown, as far as I understood he extended the integerupdown to customize it's style I tried to apply the same style on the combox with no use...(sorry that it seems like im "asking" for a full answer but problem is that sitting around and study about wpf properly will take more time than what I have to finish the app.. =\) – crazyPixel Oct 06 '13 at 15:52
  • You could create a custom IntegerUpDown: the only things you need is a text box and two buttons. If one of the buttons is clicked, jump to the number you want. – ProgramFOX Oct 06 '13 at 15:54
  • That `xctk:` part is not even necessary: WPF has a built-in combobox. Try without `xctk:` – ProgramFOX Oct 06 '13 at 16:34
  • I noticed that only after posting the edit and earsed all the properties which are not related to combobox, no use though...I think ill just have to do a quick session on wpf and hack my way around (maybe placing a listener on the value and make the position on the dataset a power of two can work?..) tnx anyway bro I appreciate your try.. – crazyPixel Oct 06 '13 at 16:39
  • I suggest you to read the MSDN article on ComboBox Styles and Templates: http://msdn.microsoft.com/en-us/library/ms752094.aspx – ProgramFOX Oct 06 '13 at 16:49