Binding Integer in XAML
I am doing a windows phone 8 application. I show the fixture of the games
on this app.
I'am binding data and showing them on phone screen but when i try to bind
integer property, it does not showing. How can i handle that ?
Here is the code when i make request and get response from my web api
service;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
const string url = "MY_WEB_API_URL";
var hWebRequest = (HttpWebRequest)WebRequest.Create(url);
hWebRequest.Method = "GET";
hWebRequest.BeginGetResponse(FixtureLoadCompleted, hWebRequest);
}
private void FixtureLoadCompleted(IAsyncResult ar)
{
var request = (HttpWebRequest)ar.AsyncState;
var response = (HttpWebResponse)request.EndGetResponse(ar);
using (var streamReader = new
StreamReader(response.GetResponseStream()))
{
_json = streamReader.ReadToEnd();
Fixturedetail =
JsonConvert.DeserializeObject<FixtureDetailApi.RootObject>(_json);
}
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
StageName.ItemsSource
=
new[]
{Fixturedetail.Dates.FirstOrDefault()};
});
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Fixture.ItemsSource
=
Fixturedetail.Dates;
});
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
RoundName.ItemsSource
=
new[]
{
Fixturedetail.Dates.FirstOrDefault()
};
});
}
and here is how i bind it in xaml ;
<phone:LongListSelector x:Name="Fixture" Height="600" Background="White"
Margin="10,154,10,46" Grid.Row="1">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<phone:LongListSelector ItemsSource="{Binding
Path=Matches}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal"
Height="50">
<Border BorderBrush="Gray"
BorderThickness="0,1,1,1"
Background="#FFFFFFF7" Opacity="0.7">
<TextBlock Foreground="Black"
Text="{Binding
Path=ExtraProperties.Hour}"
Width="55" TextAlignment="Center"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
FontSize="{StaticResource
PhoneFontSizeNormal}"/>
</Border>
<Border BorderBrush="Gray"
BorderThickness="0,1,1,1"
Background="#FFFFFFF7" Opacity="0.7">
<TextBlock Foreground="Black"
Text="{Binding
Path=HomeTeam.Name}" Width="160"
TextAlignment="Right"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
FontSize="{StaticResource
PhoneFontSizeNormal}"
Margin="0,0,10,0"/>
</Border>
<Border BorderBrush="Gray"
BorderThickness="0,1"
Background="White" Opacity="0.7">
<TextBlock Foreground="Red"
Text="{Binding
Path=CurrentHomeTeamScore}"
Width="15" TextAlignment="Center"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
FontSize="{StaticResource
PhoneFontSizeNormal}"/>
</Border>
<Border BorderBrush="Gray"
BorderThickness="0,1"
Background="White" Opacity="0.7">
<TextBlock Foreground="Red"
Text="-" TextWrapping="Wrap"
Width="10" TextAlignment="Center"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontSize="{StaticResource
PhoneFontSizeNormal}"/>
</Border>
<Border BorderBrush="Gray"
BorderThickness="0,1"
Background="White" Opacity="0.7">
<TextBlock Foreground="Red"
Text="{Binding
Path=CurrentAwayTeamScore}"
Width="15" TextAlignment="Center"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
FontSize="{StaticResource
PhoneFontSizeNormal}"/>
</Border>
<Border BorderBrush="Gray"
BorderThickness="1,1,0,1"
Background="#FFFFFFF7" Opacity="0.7">
<TextBlock Foreground="Black"
Text="{Binding
Path=AwayTeam.Name}" Width="160"
TextAlignment="Left"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
FontSize="{StaticResource
PhoneFontSizeNormal}"
Margin="5,0,0,0"/>
</Border>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
As you see here, i got no problem when i try to bind
"ExtraProperties.Hour" , "HomeTeam.Name", "AwayTeam.Name",
But when i try to bind "CurrentHomeTeamScore" and "CurrentAwayTeamScore"
they are not showing on screen. I thought it can be cause of string & int
difference. Is there any way to handle this issue ?
Waiting your helps. Thank you.
No comments:
Post a Comment