Reputation: 1116
must be a silly one but I can't figure out what is wrong...
I do not manage to properly declare my converter class into my XAML WPF View:
<controls:MetroWindow x:Class="AFF00018.View.ControlReport"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="Report" Height="600" Width="850" WindowStartupLocation="CenterScreen" ShowSystemMenuOnRightClick="False"
BorderBrush="#6593CF" BorderThickness="2" AllowDrop="False" ResizeMode="NoResize"
xmlns:Converters ="clr-namespace:AFF00018.Tools.Converters"
>
<controls:MetroWindow.Resources>
<Converters:Tray_Converter x:Key="Tray_Converter" />
</controls:MetroWindow.Resources>
<Grid >
...
<DataGrid Grid.Row="1" ItemsSource="{Binding IncorrectInserts}" AutoGenerateColumns="False" Style="{x:Null}"
Margin="15" IsReadOnly="True" SelectionMode="Single" ColumnWidth="100" RowHeight="50" >
<DataGrid.Columns>
<DataGridTextColumn Width="0.1666*" Header="Réf."
Binding="{Binding Tray, Converter={StaticResource Tray_Converter}}" />
</DataGrid.Columns>
</DataGrid>
...
</Grid>
</controls:MetroWindow>
My class is definitely defined into this NS:
namespace AFF00018.Tools.Converters
{
[ValueConversion(typeof(Tray), typeof(string))]
public class Tray_Converter : IValueConverter
{
...
}
}
Compiler says that: Tray_Converter does not exist in namespace "clr-namespace:AFF00018.Tools.Converters" It stops displaying the displayer because of this error.
It still runs. The Convert method of the converter actually gets hit. But its value parameter is always null although this is not the case in the database.
What did I miss?
Upvotes: 1
Views: 258
Reputation: 3612
Change
xmlns:Converters ="clr-namespace:AFF00018.Tools.Converters"
to
xmlns:Converters="using:AFF00018.Tools.Converters"
and you should be good. I did notice there was space between Converters
and =
but probably just a typo
Upvotes: 1