Tech Off Post

Single Post Permalink

View Thread: WPF how to rise the custom event handler in user contorl in a list.
  • User profile image
    whiteBox85

    I have a user control called (ProfileControl) which has a image with two textblock and a button. What I want is to show the data from the SQL Server in the main page of my application view each control next to each other horizontally. And respond when I press the button in the control.

    <ListBox Name="profileList" ItemsSource="{Binding}">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                </ListBox>

    From Code behind I did [code]this.profileList.ItemsSource = dbObj.GetDbData();[/code] and it is working properly.

    The only thing missing is I need to enable the event handle of the user control (which is a button) which is I need to write in the xmal (OnClickUserControl="UC_OutButton" // which is the event handler and the target method).

    But I don't know how to do.. Please advise me.