Positioning UIElement in Custom Control

I am developing a Custom Control, where there is a TextBox and a Button placed inside the Grid.

The thing is when I set a Custom Property for the UserControl Say - Left : the Button should be displayed before the TextBox, and for Right the Button should be displayed on the right side of the text box.

Since, I am defining both the elements in a Grid - am not able to position as per my requirements.


If you have to use a Grid, You can make your Grid have 3 columns and switch the TextBox Grid.Column based on your custom property.

    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="Auto" />
  <Button Grid.Column="1"
          Content="Some Text" />
  <TextBox Text="Test">
      <Style TargetType="{x:Type TextBox}">
        <Setter Property="Grid.Column"
                Value="0" />
          <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                        AncestorType={x:Type UserControl}},
            <Setter Property="Grid.Column"
                    Value="2" />

you can switch the {x:Type UserControl} in the DataTrigger to your {x:Type CustomUserControl}

Need Your Help

Audio Toolbox sound change problem

iphone objective-c audio audiotoolbox

i'm new in iphone programin and i wrote a little animation program. i used audiotoolbox frame for sound and it was working.

WPF Validation of Textbox, what should the binding look like?

.net wpf validation xaml textbox

I'm trying to validate a textbox in WPF. I found some examples on the internet and I've put together some things. But right now it just validates everything as if it was wrong. I was told it's my

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.