Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# windows phone ListBox是否具有asp:Repeater的OnItemDataBound类事件?_C#_Windows Phone 7_Listbox - Fatal编程技术网

C# windows phone ListBox是否具有asp:Repeater的OnItemDataBound类事件?

C# windows phone ListBox是否具有asp:Repeater的OnItemDataBound类事件?,c#,windows-phone-7,listbox,C#,Windows Phone 7,Listbox,在Web表单中,Repeater有一个事件OnItemDataBound。 Windows Phone应用程序中的ListBox是否有类似事件? 我正在尝试开发一些类似聊天信息的东西,我需要在不同的侧面对齐StackPanel。 有什么想法吗 Xaml 代码: 在每次迭代中,我希望根据iClient的值在不同的侧面对齐StackPanel Xaml: 代码: 不,据我所知,请详细说明问题,以便我们可以找到解决问题的替代方案 <ListBox Name="TicketReplyListBox

在Web表单中,Repeater有一个事件OnItemDataBound。 Windows Phone应用程序中的ListBox是否有类似事件? 我正在尝试开发一些类似聊天信息的东西,我需要在不同的侧面对齐StackPanel。 有什么想法吗

Xaml

代码:

在每次迭代中,我希望根据iClient的值在不同的侧面对齐StackPanel

Xaml:

代码:


不,据我所知,请详细说明问题,以便我们可以找到解决问题的替代方案
<ListBox Name="TicketReplyListBox" >
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Background="Blue" MaxHeight="200" Width="400" HorizontalAlignment="Left">
                <TextBlock Text="{Binding ContentText}"
                     FontSize="18"
                     FontFamily="\Resources\Fonts\sylfaen.ttf#sylfaen"
                     FontWeight="Bold"
                     TextWrapping="Wrap"
                     Margin="6,12,6,6"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Top" />
                <TextBlock Text="{Binding Date}"
                     HorizontalAlignment="Right"
                     VerticalAlignment="Top"
                     Margin="6,0,6,6"
                     FontSize="18"
                     FontFamily="Segoe WP SemiLight" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
public class TicketReplyModel
{
    public int TicketID { get; set; }
    public string ContentText { get; set; }
    public bool IsClient { get; set; }
    public DateTime Date { get; set; }
}
Service1Client WCFClient = new ServiceReference1.Service1Client();
public ActiveTicketDetail()
{
     InitializeComponent();
     WCFClient.GetTicketReplyListCompleted += new EventHandler<GetTicketReplyListCompletedEventArgs>(WCFClient_GetTicketReplyListCompleted);
     WCFClient.GetTicketReplyListAsync(84);  
}

void WCFClient_GetTicketReplyListCompleted(object sender, GetTicketReplyListCompletedEventArgs e)
{
     List<TicketReplyModel> TickteReptyList = new List<TicketReplyModel>();
     TickteReptyList = e.Result.ToList();
     TicketReplyListBox.ItemsSource = TickteReptyList;
}
<ScrollViewer>
    <StackPanel x:Name="Tikcetst">
    </StackPanel>
</ScrollViewer>
public ActiveTicketDetail()
        {
            InitializeComponent();
            WCFClient.GetTicketReplyListCompleted += new EventHandler<GetTicketReplyListCompletedEventArgs>(WCFClient_GetTicketReplyListCompleted);
            WCFClient.GetTicketReplyListAsync(84);



        }

        void WCFClient_GetTicketReplyListCompleted(object sender, GetTicketReplyListCompletedEventArgs e)
        {
            List<TicketReplyModel> TickteReptyList = new List<TicketReplyModel>();
            TickteReptyList = e.Result.ToList();
            TickteReptyList.ForEach(item =>
            {
                TextBlock txtBl1 = new TextBlock();
                txtBl1.Text = item.ContentText;
                txtBl1.Padding = new Thickness(5);
                txtBl1.FontSize = 18;
                TextBlock txtBl2 = new TextBlock();
                txtBl2.Text = item.Date.ToShortDateString();
                txtBl2.Padding = new Thickness(5);                
                txtBl2.FontSize = 14;
                txtBl2.HorizontalAlignment = HorizontalAlignment.Right;
                StackPanel st = new StackPanel();
                st.Children.Add(txtBl1);
                st.Children.Add(txtBl2);

                st.Width = 400;                
                st.HorizontalAlignment = item.IsClient ? HorizontalAlignment.Right : HorizontalAlignment.Left;
                st.Margin = new Thickness(5);
                string fileName = item.IsClient ? "Images/MessagecollorMe.png" : "Images/MessagecollorBank.png";
                BitmapImage image = new BitmapImage(new Uri(fileName, UriKind.Relative));
                ImageBrush brush = new ImageBrush();
                brush.ImageSource = image;
                st.Background = brush;
                Tikcetst.Children.Add(st);
            });
        }