kolibri
جمعه 23 بهمن 1394, 11:14 صبح
سلام؛
من یه لیست باکس دارم که از طریق بایندینگ مقدارهای اون رو پر می کنم:
<ListBox x:Name="HomeList" Background="White" Grid.Row="1" Margin="20,10,20,10" SelectionChanged="HomeList_SelectionChanged" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<UserControl>
</UserControl>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<RelativePanel>
<Button Name="Do" FontFamily="Segoe MDL2 Assets" Content="" Background="GreenYellow" Foreground="White" Tapped="Do_Tapped" RelativePanel.AlignRightWithPanel="True" Height="35" MinHeight="35" Width="55"/>
<Button Name="Edit" FontFamily="Segoe MDL2 Assets" Content="" Background="Gray" Foreground="White" RelativePanel.LeftOf="Do" Height="35" MinHeight="35" Tapped="Edit_Tapped"/>
<Button Name="Dell" FontFamily="Segoe MDL2 Assets" Content="" Background="Red" Foreground="White" Tapped="Dell_Tapped" RelativePanel.LeftOf="Edit" Height="35" MinHeight="35" />
</RelativePanel>
<StackPanel Name="stkMover" Orientation="Horizontal" ManipulationMode="TranslateX" >
<StackPanel.Resources>
<Storyboard x:Name="sb1">
<DoubleAnimation Duration="0:0:0.1" To="0" Storyboard.TargetProperty="(StackPanel.RenderTransform).(TranslateTransform.X )" Storyboard.TargetName="GRIDO"/>
</Storyboard>
<Storyboard x:Name="sb2">
<DoubleAnimation Duration="0:0:0.1" To="-100" Storyboard.TargetProperty="(StackPanel.RenderTransform).(TranslateTransform.X )" Storyboard.TargetName="GRIDO"/>
</Storyboard>
</StackPanel.Resources>
<StackPanel.RenderTransform>
<TranslateTransform/>
</StackPanel.RenderTransform>
<Ellipse Width="40" Height="40" Margin="0,0,20,0" >
<Ellipse.Fill>
<ImageBrush Stretch="Fill" ImageSource="{Binding Picture,Converter={StaticResource ImageConverter}}"/>
</Ellipse.Fill>
</Ellipse>
<StackPanel Orientation="Vertical" Background="White" Tag="{Binding}">
<TextBlock Text="{Binding Title}" FontSize="20" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Grid.ColumnSpan="2"/>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBlock Text="{Binding People,Converter={StaticResource TextConverter},ConverterParameter=\with \{0:d\}}" FontSize="13" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Foreground="#B2000000"/>
<TextBlock Text="{Binding Time,Converter={StaticResource TextConverter},ConverterParameter=\at \{0:f\}}" FontSize="13" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Foreground="#B2000000" Margin="3,0,5,0" Tag="{Binding}"/>
<TextBlock Text="{Binding Location,Converter={StaticResource TextConverter},ConverterParameter=\in \{0:d\}}" FontSize="13" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Foreground="#B2000000" MinWidth="Infinity"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
من می تونم با رویداد SelectionChanged به روش زیر IDبایند شده در اون آیتم رو بگیرم:
private void HomeList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// db اسم کلاسمون هست که ازش بایند می کنیم!
var selected = HomeList.SelectedItem as db;
//ID هم هون داده ای هست که بایند شده!
if(selected!=null)
{
string date = selected.Id.ToString();
}
}
اما مشکل من اینه که:
نمی تونم استوری بورد رو صدا بزنم تا اجرا بشه. استوری بورد بعد از پایان کشیدن StackPanel با نام stkMover شروع میشه.
می خوام بدون رویداد SelectionChanged به مقدار IDدسترسی داشته بشام. بعد از کشیدن stkMover و اتمام استوری بورد سه دکمه مربوطه نمایش داده میشه. من می خوام برای مثال با کلیک روی دکمه del، ردیفی که اون IDرو داره در دیتابیسم حذف کنم.
ببخشید خیلی مبتدیانه توضیح دادم.
من یه لیست باکس دارم که از طریق بایندینگ مقدارهای اون رو پر می کنم:
<ListBox x:Name="HomeList" Background="White" Grid.Row="1" Margin="20,10,20,10" SelectionChanged="HomeList_SelectionChanged" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<UserControl>
</UserControl>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<RelativePanel>
<Button Name="Do" FontFamily="Segoe MDL2 Assets" Content="" Background="GreenYellow" Foreground="White" Tapped="Do_Tapped" RelativePanel.AlignRightWithPanel="True" Height="35" MinHeight="35" Width="55"/>
<Button Name="Edit" FontFamily="Segoe MDL2 Assets" Content="" Background="Gray" Foreground="White" RelativePanel.LeftOf="Do" Height="35" MinHeight="35" Tapped="Edit_Tapped"/>
<Button Name="Dell" FontFamily="Segoe MDL2 Assets" Content="" Background="Red" Foreground="White" Tapped="Dell_Tapped" RelativePanel.LeftOf="Edit" Height="35" MinHeight="35" />
</RelativePanel>
<StackPanel Name="stkMover" Orientation="Horizontal" ManipulationMode="TranslateX" >
<StackPanel.Resources>
<Storyboard x:Name="sb1">
<DoubleAnimation Duration="0:0:0.1" To="0" Storyboard.TargetProperty="(StackPanel.RenderTransform).(TranslateTransform.X )" Storyboard.TargetName="GRIDO"/>
</Storyboard>
<Storyboard x:Name="sb2">
<DoubleAnimation Duration="0:0:0.1" To="-100" Storyboard.TargetProperty="(StackPanel.RenderTransform).(TranslateTransform.X )" Storyboard.TargetName="GRIDO"/>
</Storyboard>
</StackPanel.Resources>
<StackPanel.RenderTransform>
<TranslateTransform/>
</StackPanel.RenderTransform>
<Ellipse Width="40" Height="40" Margin="0,0,20,0" >
<Ellipse.Fill>
<ImageBrush Stretch="Fill" ImageSource="{Binding Picture,Converter={StaticResource ImageConverter}}"/>
</Ellipse.Fill>
</Ellipse>
<StackPanel Orientation="Vertical" Background="White" Tag="{Binding}">
<TextBlock Text="{Binding Title}" FontSize="20" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Grid.ColumnSpan="2"/>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<TextBlock Text="{Binding People,Converter={StaticResource TextConverter},ConverterParameter=\with \{0:d\}}" FontSize="13" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Foreground="#B2000000"/>
<TextBlock Text="{Binding Time,Converter={StaticResource TextConverter},ConverterParameter=\at \{0:f\}}" FontSize="13" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Foreground="#B2000000" Margin="3,0,5,0" Tag="{Binding}"/>
<TextBlock Text="{Binding Location,Converter={StaticResource TextConverter},ConverterParameter=\in \{0:d\}}" FontSize="13" FontFamily="Assets/Font/calibril.ttf#Calibri Light" Foreground="#B2000000" MinWidth="Infinity"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
من می تونم با رویداد SelectionChanged به روش زیر IDبایند شده در اون آیتم رو بگیرم:
private void HomeList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// db اسم کلاسمون هست که ازش بایند می کنیم!
var selected = HomeList.SelectedItem as db;
//ID هم هون داده ای هست که بایند شده!
if(selected!=null)
{
string date = selected.Id.ToString();
}
}
اما مشکل من اینه که:
نمی تونم استوری بورد رو صدا بزنم تا اجرا بشه. استوری بورد بعد از پایان کشیدن StackPanel با نام stkMover شروع میشه.
می خوام بدون رویداد SelectionChanged به مقدار IDدسترسی داشته بشام. بعد از کشیدن stkMover و اتمام استوری بورد سه دکمه مربوطه نمایش داده میشه. من می خوام برای مثال با کلیک روی دکمه del، ردیفی که اون IDرو داره در دیتابیسم حذف کنم.
ببخشید خیلی مبتدیانه توضیح دادم.