经过多次尝试,我无法将我的集合(CollectionViewSource)从我的View传递给我的转换器。 (VisibilityColumn)
Xaml(WPF):这里我的集合安排在源数据网格中。很遗憾,我无法恢复此源,以便在我的转换器中使用。问题可以找到标记。
let redis = require('redis'),
BitSet = require('./bitset');
let client = redis.createClient();
// create some data
let bs = new BitSet;
bs.set(0, 1);
bs.set(31, 1);
// calculate how many bytes we'll need
var numBytes = Math.ceil(bs.msb()/8);
// construct a buffer with that much space
var buffer = new Buffer(numBytes);
// for each byte
for (var i = 0; i < numBytes; i++) {
var byte = 0;
// iterate over each bit
for (var j = 0; j < 8; j++) {
// slide previous bits to the left
byte <<= 1;
// and set the rightmost bit
byte |= bs.get(i*8+j);
}
// put this byte in the buffer
buffer[i] = byte;
}
// now we have a complete buffer to use as our value in Redis
client.set('bitset', buffer, function (err, result) {
client.getbit('bitset', 31, function (err, result) {
console.log('Bit 31 = ' + result);
client.del('bitset', function () {
client.quit();
});
});
});
转换器:CollectionViewSource(CurrentCollection)必须与我的视图链接。
<D:DataGridRecherche/>
<D:DataGridTemplate x:Name="Datagrid" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" ItemsSource="{Binding DataProduits,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<DataGrid.Resources>
<CollectionViewSource x:Key="Currentcollection" Source="{Binding Path=ColumnName}" />
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding Path=Prod_Id}"/>
<DataGridTextColumn Header="Désignation" Binding="{Binding Path=Prod_Des}"/>
<DataGridTextColumn Header="Statut regie" Binding="{Binding Path=Prod_Idsteap}"/>
<DataGridTextColumn Header="Ste. d'appartenance">
<DataGridTextColumn.Visibility>
<Binding Path="Prod_Cloture" Converter="{StaticResource VisibilityColumn}" ConverterParameter="Prod_Cloture" Mode="TwoWay" >
<Binding> <!-- the problem seems to be here -->
<Converters:VisibilityColumn CurrentCollection="{StaticResource Currentcollection}"/>
</Binding>
</Binding>
</DataGridTextColumn.Visibility>
</DataGridTextColumn>
</DataGrid.Columns>
</D:DataGridTemplate>
答案 0 :(得分:0)
感谢您的回答,但转换器并不总是启动。 我认为还是正确应用了你的代码。
<DataGridTextColumn Header="Ste. d'appartenance" Binding="{Binding Path=Prod_Cloture}">
<DataGridTextColumn.Visibility>
<Binding Path="Prod_Cloture" ConverterParameter="Prod_Cloture" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.Converter>
<Converters:VisibilityColumn CurrentCollection="{StaticResource Currentcollection}"/>
</Binding.Converter>
</Binding>
</DataGridTextColumn.Visibility>
</DataGridTextColumn>