0

Is it possible to bind the textbox outside the itemssource of itemcontrol.

I Just start coding wpf so I don't have any idea.

This is my code:

<Page x:Class="InformationSys.View.Page1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:InformationSys.View"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
      Title="Page1"
      DataContext="{Binding Information, Source={StaticResource Locator}}">


    <ItemsControl ItemsSource="{Binding Gender}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width=".4*"/>
                        <ColumnDefinition Width=".3*" />
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <CheckBox IsChecked="{Binding IsChecked}" FlowDirection="RightToLeft" Grid.Column="0" VerticalAlignment="Bottom">
                        <TextBlock Text="{Binding Gen_Type}"/>
                    </CheckBox>
                    <TextBox x:Name="textBox5" Grid.Column="1" Grid.Row="4" Margin="20 0 0 0" />
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</Page>

Thanks!

Marco Bagiacchi
  • 334
  • 2
  • 20
koyuki
  • 9
  • 2
  • 1
    Well, you can use x:Name on the element that contains the DataContext that you want to bind to. What do you want to bind your textblock to? – Lupu Silviu Nov 10 '16 at 07:46
  • 1
    i want to bind it to the user name table, so when I check the checkbox and type the name of the user it will be save the gender and the name. – koyuki Nov 10 '16 at 08:01
  • this provides a full example:http://stackoverflow.com/questions/40372765/xceed-datagrid-showing-combobox/40376895#40376895 – Mat Nov 10 '16 at 09:53
  • What do you want? You want create a list of user or just edit a single user? – Red Wei Nov 13 '16 at 12:30

0 Answers0