Dyskusje na temat języka C# oraz biblioteki .NET
arti
Początkujący
Posty: 23 Dołączył(a): środa, 6 sierpnia 2014, 16:43
Post
przez arti » wtorek, 11 listopada 2014, 21:54
Witam, mam taki kod w xaml
Code: Zaznacz cały
<DataGridTemplateColumn Header="Status" Width="120">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<ComboBox x:Name="_status" Text="{Binding status}" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Ktos moze mi wyjasnic czemu nie mam dostepu do ComboBox _status ?
Chce uzyc tego jako _status.ItemsSource = status.jobStatus(); ale wywala blad:
Error 1 The name '_status' does not exist in the current context
Morfidon
Administrator
Posty: 1332 Dołączył(a): wtorek, 5 sierpnia 2008, 21:48
Contact:
Post
przez Morfidon » środa, 12 listopada 2014, 01:27
Sprawdź czy masz odpowiednio podlinkowane wszystko np. nadając atrybut name w innych miejscach w tym pliku.
arti
Początkujący
Posty: 23 Dołączył(a): środa, 6 sierpnia 2014, 16:43
Post
przez arti » środa, 12 listopada 2014, 14:54
tak wyglada caly kod:
Code: Zaznacz cały
<UserControl x:Class="COBRA.Menu.ProductionPlan"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920">
<Grid>
<!--TITLE-->
<Grid Height="100" Width="1920" VerticalAlignment="Top" HorizontalAlignment="Left" Background="#FF191818">
<Button x:Name="_btnBack" Content="Back" Height="40" Width="110" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="20,30,0,0"
Background="#FF706A6A" Foreground="White" FontWeight="Bold" FontFamily="Arial Black" FontSize="15" Click="_btnBack_Click" BorderThickness="3" BorderBrush="#FFA49E9E" />
<TextBlock Text="Production Plan" Height="70" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="300,20,0,0"
FontSize="60" FontWeight="Bold" Foreground="White" FontFamily="Arial" />
</Grid>
<Grid Margin="0,100,0,0">
<DataGrid x:Name="_dataGrid" ItemsSource="{Binding Order}" AutoGenerateColumns="False" Loaded="DataGrid_Loaded" RowBackground="#FFD8D5D5" >
<DataGrid.Columns>
<DataGridTemplateColumn Header="Order ID" Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding orderId}" TextAlignment="Center" FontWeight="Bold" />
<TextBlock Text="{Binding xOrderId}" TextAlignment="Center"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridComboBoxColumn x:Name="_status" TextBinding="{Binding status}" Header="Status" Width="120" />
<DataGridComboBoxColumn x:Name="_queue" TextBinding="{Binding queue}" Header="Queue" Width="120" />
<DataGridTextColumn x:Name="_notes" Binding="{Binding notes}" Header="Notes" Width="200"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Grid>
</UserControl>
_status wyrzucilem z template i dziala, jak wroce do poprzedniego kodu to nie wyswietla zawartosci. Przypomne ze Binding do status tylko ma wyswietlic obecna wartosc rekordu. Dalej w kodzie mam
Code: Zaznacz cały
_status.ItemsSource = statuses.jobStatus();
I to dziala perfect. Wrzuce do template i nie widzi