Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to create Radiobuttons dynamically in WPF with the input given by user ?

$
0
0

Hi,

  I want to create  RadioButtons  in a stackpanel dynamically  based  on the  user  input in a textbox.  I am  unable  to bind it and no radiobuttons  are visible . My xaml code is  below :--- 

<Grid>       
        <TextBlock  Name="textBlock1" Text="Enter the no of Radio Buttons :" />
        <TextBox  Name="textBox1" VerticalAlignment="Top">
            <TextBox.Text>
                <Binding  Path="RDBCount" UpdateSourceTrigger="PropertyChanged" NotifyOnSourceUpdated="True"/>
            </TextBox.Text>
        </TextBox>                 
        <StackPanel >
            <ItemsControl ItemsSource="{Binding States}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <RadioButton GroupName="Same" Content="{Binding StateName, NotifyOnSourceUpdated=True}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
           </StackPanel>
    </Grid> 

In the  code  page -  States  is  a collection  of  Radiobutton  and RDBCount is no of  count  which binded  with user input in a textbox.

Please  help  me  how to bind this two properties to work.

 Thanks-


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>