XamarinForms ListView项目填写

时间:2015-05-29 15:06:56

标签: windows-phone-8 xamarin xamarin.forms

如何强制我的TemplateItem展开并填充ListView的整个宽度?

如您在屏幕截图中看到的那样,listView有一个红色背景,我的项目有一个白色背景。

DataTemplate的代码:

  <DataTemplate x:Key="InformationMessageTemplate">
    <StackLayout Orientation="Horizontal" BackgroundColor="#FFFFFF" HorizontalOptions="FillAndExpand">
      <Label FontAttributes="Bold" Text="{Binding Sender}"  />
      <Label Text=" chegou na sala" HorizontalOptions="FillAndExpand"/>
    </StackLayout>
  </DataTemplate>

enter image description here

1 个答案:

答案 0 :(得分:2)

尝试将StackLayout放入ViewCell中:

// set our headers to pass in cURL
$headers = array(
    'Content-type: text/xml;charset="utf-8"',
    'Accept: text/xml',
    'Cache-Control: no-cache',
    'Pragma: no-cache',
    'SOAPAction: ' . $action,
    'Content-length: '.strlen($soap)
 );

 // initiate cURL
 try {
    $_ch = curl_init();
    curl_setopt($_ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($_ch, CURLOPT_URL, WEB_SERVICE_URL);
    curl_setopt($_ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($_ch, USERPWD, USER_ID . ":" . PASSWORD);
    curl_setopt($_ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($_ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($_ch, CURLOPT_POST, true);
    curl_setopt($_ch, CURLOPT_POSTFIELDS, $soap);
    curl_setopt($_ch, CURLOPT_HTTPHEADER, $headers);

    // process the request and get the result back
    $response = curl_exec($_ch);
    curl_close($_ch);
    return $response;
 } catch (Exception $e) {
    capDebug(__FILE__, __LINE__, "Error calling the web service: " . $e->getMessage(), "/tmp/errors.log");
    return false;
 }